मैं एक डेबियन बॉक्स में vsFTP स्थापित। जब ftp कमांड का उपयोग कर मैन्युअल रूप से फ़ाइल अपलोड करें, तो यह ठीक है। यानी, निम्नलिखित सत्र काम करता है:एफ़टीपी अपलोड फ़ाइल मैन्युअल रूप से काम करता है, लेकिन का उपयोग कर विफल रहता है अजगर ftplib
[email protected]:~$ ftp xxx.xxx.xxx.xxx 5111 Connected to xxx.xxx.xxx.xxx. 220 Hello,Welcom to my FTP server. Name (xxx.xxx.xxx.xxx:john): ftpuser 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> put st.zip local: st.zip remote: st.zip 200 PORT command successful. Consider using PASV. 150 Ok to send data. 226 File receive OK. 12773 bytes sent in 0.00 secs (277191.8 kB/s) ftp> 221 Goodbye.
(कृपया नोट किया कि जैसा कि ऊपर, मैं vsFTP सर्वर कॉन्फ़िगर किया गया एक गैर-डिफ़ॉल्ट पोर्ट का उपयोग करने के लिए किसी कारण जैसे 5111)
अब जब मैं में एक पटकथा लिखने फ़ाइल प्रोग्रामेटिक रूप से अपलोड करने के लिए पायथन, यह असफल रहा। त्रुटि कहते हैं, 'समय के लिए बाहर', के रूप में निम्नलिखित सत्र दिखाता है:
[email protected]:~$ ipython Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14) Type "copyright", "credits" or "license" for more information. IPython 0.8.4 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object'. ?object also works, ?? prints more. In [1]: import ftplib In [2]: ftp=ftplib.FTP() In [3]: ftp.connect('xxx.xxx.xxx.xxx','5111') Out[3]: "220 Hello,Welcom to my FTP server." In [4]: ftp.login('ftpuser','ftpuser') Out[4]: '230 Login successful.' In [5]: f=open('st.zip','rb') In [6]: ftp.storbinary('STOR %s' % 'my_ftp_file.zip', f) --------------------------------------------------------------------------- error Traceback (most recent call last) ... /usr/lib/python2.5/ftplib.pyc in ntransfercmd(self, cmd, rest) 322 af, 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 rest is not None: 326 self.sendcmd("REST %s" % rest) /usr/lib/python2.5/socket.pyc in connect(self, *args) error: (110, 'Connection timed out')
मुझे लगता है कि मेरी vsFTP सर्वर में कुछ गलत config वहाँ है, लेकिन यह पता नहीं कर सकते हैं। कोई भी मदद कर सकता है?
मेरी vsFTP config है:
listen=YES connect_from_port_20=YES listen_port=5111 ftp_data_port=5110 # Passive FTP mode allowed pasv_enable=YES pasv_min_port=5300 pasv_max_port=5400 max_per_ip=2
काम करता है यही कारण है कि! धन्यवाद जिम लेकिन क्यों पाइथन ftplib स्वचालित रूप से पासिव मोड का उपयोग नहीं कर सकता है? मेरा vsFTP वास्तव में निष्क्रिय मोड को अनुमति देने के लिए कॉन्फ़िगर किया गया है। क्या यह vsFTP में कॉन्फ़िगरेशन गलती हो सकती है? मैंने अपना प्रश्न पोस्ट संपादित किया है और वहां अपना vsftpd.conf जोड़ा है। –
समस्या ftplib में लेकिन vsFTP है, जो किसी कारण से निष्क्रिय मोड की अनुमति नहीं दे में नहीं है। क्या आप सुनिश्चित हैं कि vsFTP कॉन्फ़िगर सही जगह पर है? –
हाँ, जिम, यह vsFTP config की एक समस्या है। आखिरकार मुझे कारण मिला: मेरा बनामएफटीपी एनएटी में तैनात है। तो भले ही मैंने vsFTP विकल्प "pasv_enable = YES" सेट किया है, मुझे भी एक और विकल्प "pasv_address = my.external.ip.address" सेट करना होगा। उसके बाद, सबकुछ ठीक है! धन्यवाद, हार्दिक समुदाय के लिए धन्यवाद! –