Reputation: 11
Suppose I made a file using Paramiko module in CentOS and accessing it from a Python script in Windows:
stdin,stdout,stderr=ssh.exec_command("touch Hello")
Then how can I write something and save the file?
print "hello,world"
Please help me I am stuck here.
Upvotes: 1
Views: 4577
Reputation: 202282
Use the SFTP to upload the file contents. Do not try to hack this with shell commands.
transport = paramiko.Transport(("host", 22))
transport.connect(username = "username", password = "password")
sftp = paramiko.SFTPClient.from_transport(transport)
f = sftp.open("/path/to/remote/file", "wb")
f.write("hello,world")
f.close()
Upvotes: 1