tags:

views:

37

answers:

2

hi, 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 giving me following error: socket.gaierror: [Errno 11001] getaddrinfo failed.. can somebody plz help me out with this.

+1  A: 

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.

ars
hi, it still dint work. m getting this error: socket.error: [Errno 10061] No connection could be made because the target machine actively refused it..???
rushi
@rushi: this means that there is no server program listening at the specified endpoint (ip address + port). One possibility is that your have the wrong port -- are you sure it's port 22? Try the default port 21.
ars
yeah i tried that too still giving the same error.actually m new to this thats y dont know much...cud u tell me wat cud be the possible mistake i hv made????
rushi
A: 

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.

ghostdog74
yeah worked...thanks..
rushi
hi, though it is getting connected its not accepting the credentials m giving..do i need to make any changes in any files on either the remote machine or in the laocal machine for that.
rushi
so you are using FTP right? if its not accepting the credential then check your password and user name...
ghostdog74