I'm on Windows 7.
I cannot connect to my iPad with a simple Python script:
HOST = '192.168.1.122'
try:
f = ftplib.FTP(HOST)
except (socket.error, socket.gaierror), e:
MessageBox.Show('ERROR: cannot reach "%s"' % HOST)
return
try:
f.connect(HOST,2121)
f.login()
except ftplib.error_perm:
MessageBox.Show('ERROR: cannot login anonymously')
f.quit()
return
The errors I have is "getaddrinfo returns an empty list" and the "cannot reach..." message... Cannot solve it...
I tried to FTP with several programs on the iPad without success. If I FTP via DOS box or using a FTP software it works. I tried as well another FTP server on my PC and it works.
I am forced to use port 2121, so can't change it.
Any clue or experience?
You should read docs before anything:
class ftplib.FTP([host[, user[, passwd[, acct[, timeout]]]]]) Return a new instance of the FTP class. When host is given, the method call connect(host) is made. When user is given, additionally the method call login(user, passwd, acct) is made (where passwd and acct default to the empty string when not given). The optional timeout parameter specifies a timeout in seconds for blocking operations like the connection attempt (if is not specified, the global default timeout setting will be used).
So, if you do f = ftplib.FTP(HOST) it fails because it will try to connect to standard port (21) and not 2121. You should get an instance of ftplib and later use f.connect(HOST, 2121).
http://docs.python.org/library/ftplib.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With