开发者

Transfer files from windows machine to remote solaris machine using python script

i used following code to establish connection between my local machine and the remote machine :

import os, sys, ftplib

nonpassive=False
remotesite= '10.88.203.21:22'
remoteuser='root'
remotepass='v-peg8!@#'
localdir= "c:\\.."
print "connecting"

connection=ftplib.FTP(remotesite)
print "successfully connected"

connection.login(remoteuser,remotepass)

if nonpassive:
    connection.set_pasv(False)

But its g开发者_开发问答iving me following error: socket.gaierror: [Errno 11001] getaddrinfo failed.. can somebody plz help me out with this.


You need to specify the port as a separate argument, not in the way you have it in remotesite. Try:

remotesite = '10.88.203.21'
port = 22
connection = ftplib.FTP(remotesite, port)

See the FTP docs for more information.


If its port 22, then you are using wrong port, since most systems use 22 for SSH protocol. Assuming that 22 is normal SSH port, you should really use scp/sftp. (try paramiko for Python). If you are sure the remote server is running FTP, then use the default port 21.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜