Ejemplo 1: archivo put de python sftp
import pysftp
srv = pysftp.Connection(host="www.destination.com", username="root",
password="password",log="./temp/pysftp.log")
with srv.cd('public'): #chdir to public
srv.put('C:UsersXXXDropboxtest.txt') #upload file to nodejs/
# Closes the connection
srv.close()
Ejemplo 2: python connect sftp
import pysftp
import sys
path = './THETARGETDIRECTORY/' + sys.argv[1] #hard-coded
localpath = sys.argv[1]
host = "THEHOST.com" #hard-coded
password = "THEPASSWORD" #hard-coded
username = "THEUSERNAME" #hard-coded
with pysftp.Connection(host, username=username, password=password) as sftp:
sftp.put(localpath, path)
print 'Upload done.'
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)