I'm writing a class which communicates with a text file on a remote SSH server (sitting on a windows machine) using the paramiko library. I have the following line in my python app (sitting on a linux machine) which should establish a connection for appending a file;
file(pollFile, mode='a', bufsize=1)
But how do I actually go about interacting with this file I've established a conneciton with?
Thanks!
The object returned from the file call is a paramiko.SFTPFile handle, which can be interacted with using write, writelines e.g.
data = "Hello World"
file_hande = sftp_client.file(pollFile, mode='a', bufsize=1)
file_handle.write(data)
file_handle.flush()
file_handle.close()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With