FTP upload file works manually, but fails using Python ftplib -
I have installed vsFTP in a Debian box. When manually uploading the file using the FTP file, it's okay. I.e, the following session works:
JOH @ @ myhost: ~ $ ftp xxx.xxx.xxx.xxx Connect to 5111 xxx.xxx.xxx.xxx. 220 Hello, Welcom name (xxx.xxx.xxx.xxx:john) on my FTP server: ftpuser 331 Please specify password. Password: 230 Login The type of successful remote system is Unix. Using binary mode to transfer files. Ftp> put st.zip local: st.zip remote: st.zip 200 pORT Commands Consider using a successful PASV 150 is fine to send data. 226 file gets ok 12773 bytes is 0.00 seconds (277198.8 KB / S) Feet> 221 was sent in bye.
(Please note that as explained above, I have configured a FFTP server vs. for any non-default port, for example 5111 for some reason)
Now when I write a script to upload a file to Python, programmatically, this failed error says, 'Out for time', shows the following sessions as follows:
John @ Myhost: ~ $ Dragon 2.5.2 (r252: 60911, 24 January 2010, 14:53:14) IPython ta Please copy "Copyright", "Credit" or "License" for more information IPython 0.8.4 - An enhanced Interactive Python. ? -> introduction and overview of the features of IPython% Quickref -> Quick Reference Help -> Python's Self Help System Objection? -> The description object about the 'object' also works? Print more. Import ftplib in [2]: FTP = ftplib.FTP () [3]: ftp.connect ('xxx.xxx.xxx.xxx', '5111') out [3]: [1] in "hello 220, my Welcome to FTP server. "[4] In: ftp.login ('ftpuser', 'ftpuser') out [4]: '230 login successful.' In [5]: f = open ('st.zip', 'rb') [6]: FTP storbinary ('STOR% s'% 'my_ftp_file.zip', f) -------- - ------------------------------------------------- - ---------------- Error Traceback (Last Call Last) ... /usr/lib/python2.5/ftplib.pyc ntransfercmd (self, CMD, rest) 322 Air force, socktype, proto, canon, sa = socket.getaddrinfo (host, port, 0, socket.SOCK_STREAM) [0] 323 Conn = socket.socket (AF, socktype, proto) -> 324 conn.connect (SA) 325 If there is no one else: 326 self.sendcmd ("rest% s"% remaining) /usr/lib/python2.5/socket.pyc Connect (auto, * args) error: (110, 'connection time out ')
I think That there is some wrong config in my vsFTP server, but it can not help anyone understand
my vsFTP config is:
listen = yes connect_from_port_20 = yes listen_port = 5111 Ftp_data_port = 5110 # disable FTP mode permissions pasv_enable = yes pasv_min_port = 5300 pasv_max_port = 5400 max_per_ip = 2
when As long as you do not end up trying to send data, you successfully connect to the server. The difference I've seen is that ftplib di Using Holt as passive mode, while your command line is not visible to the client. Try doing
ftp.set_pasv (false)
The introduction of the transfer and what happens before it happens.
Note that non-inactive mode is essentially obsolete because it can not be used in the NAT firewall, so you must configure to allow passive mode.
Comments
Post a Comment