After much searching on Google and reviewing many stackoverflow questions, I am still at a loss. EVERY method I have attempted to get a directory listing ends with Python sending two commands, TYPE A and PASV, then it just stops talking. Any suggestions?
My Python (2.7.6) code:
from ftplib import FTP
port_num = 21
host_str = "xxxxxx"
ftp = FTP(host_str)
ftp.set_debuglevel(1)
ftp.connect(host_str, port_num)
ftp.getwelcome()
ftp.login("xxxxxx", "xxxxxx")
print "==Getting DIR..."
lines = ftp.retrlines("NLST")
print "==Got DIR..."
print "Returned files list:\n", lines
The output:
*resp* '220 Microsoft FTP Service'
*welcome* '220 Microsoft FTP Service'
*cmd* 'USER c680-750'
*resp* '331 Password required for c680-750'
*cmd* 'PASS *******'
*resp* '230 User c680-750 logged in'
==Getting DIR...
*cmd* 'TYPE A'
*resp* '200 Command okay.'
*cmd* 'PASV'
*resp* '227 Entering Passive Mode (204,77,162,69,218,190)' Traceback (most recent call last): ...
raise err error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
What FileZilla says when it successfully connects:
Status: Resolving address of xxxx
Status: Connecting to xxx.xx.xxx.xx:21...
Status: Connection established, waiting for welcome message...
Response: 220 Microsoft FTP Service
Command: USER xxxx
Response: 331 Password required for xxxx
Command: PASS *******
Response: 230 User xxxx logged in
Command: SYST
Response: 215 UNIX Type: L8
Command: FEAT
Response: 211-Extensions supported:
Response: MDTM
Response: SIZE
Response: 211 END
Status: Server does not support non-ASCII characters.
Status: Connected
Status: Retrieving directory listing...
Command: PWD
Response: 257 "xxxx" is the current directory
Command: TYPE I
Response: 200 Command okay.
Command: PORT 167,186,116,227,234,64
Response: 200 PORT command successful.
Command: LIST
Response: 150 File status okay; about to open data connection.
Response: 226 Transfer complete, closing data connection.
Status: Directory listing successful