简体   繁体   中英

Paramiko, appending file on SSH server

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 eg

data = "Hello World"
file_hande = sftp_client.file(pollFile, mode='a', bufsize=1)
file_handle.write(data)
file_handle.flush()
file_handle.close()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM