python - Send a file to a specific path in a server -


i trying send file pc many servers specific folder in server directory using 1 script, keeping things simple, trying in beginning send 1 file 1 server instead of many.

i connected server using key authentication, not need use login info in code. have used following:

import pysftp sftp  def filetransfer():     try:          s = sftp.connection(host='ip address')# server ip address inserted          remotepath='/xx/yy/file.txt'# file transferred         localpath='c:/users/david/desktop/file.txt'# file location in pc         s.put(localpath,remotepath)         s.close()      except exception, e:         print str(e)  filetransfer() 

i following exception:

attributeerror: "'connection' object has no attribute '_transport_live'" in <bound method connection.__del__ of <pysftp.connection object @ 0x0000000002e1f3c8>> 

i have tried insert server port beside ip address, did not same error.

use this

sftp.connection(host="your_host", port="your_port", username="user_name", private_key="private_key") 

if you're still having problems change private_key password

check out documentation

http://pysftp.readthedocs.org/en/release_0.2.8/pysftp.html


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -