这就是我想要完成的事情:
以下是vanilla FTP脚本中的代码:
OPEN FTPTABS.DTN.COM
TABSN_999XTEST1234
TEST8547
PUT ADMCON.TXT ./IMPORT/ADMCONS1105.TXT
GET ./IMPORT ADMCONS1105.TXT ADMCONS1105RESPONSE.TXT
QUIT
Python代码:
def test_upload():
ftp = FTP('catftptabs.dtn.com')
ftp.login(user=username, passwd=password)
# Put <Your local file name> ./IMPORT/<File name>
ftp.putcmd('ADMCON.TXT ./IMPORT/ADMCONS1105.TXT')
ftp.sendcmd('GET ./IMPORT ADMCONS1105.TXT ADMCONS1105RESPONSE.TXT')
ftp.quit()
似乎打破了ftp.sendcmd(...)行,这里是错误消息:
In[84]: ftp.putcmd('ADMCON.TXT ./IMPORT/ADMCONS1105.TXT')
In[85]: ftp.sendcmd('GET ./IMPORT ADMCONS1105.TXT ADMCONS1105RESPONSE.TXT')
Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/IPython/core/interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-85-8b7bcc0b14c2>", line 1, in <module>
ftp.sendcmd('GET ./IMPORT ADMCONS1105.TXT ADMCONS1105RESPONSE.TXT')
File "/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ftplib.py", line 272, in sendcmd
return self.getresp()
File "/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ftplib.py", line 245, in getresp
raise error_perm(resp)
ftplib.error_perm: 502 Command not recognized or allowed.
非常感谢任何帮助!