[英]ftplib.error_perm: 553 Could not create file. (Python 2.4.4)
我正在写我要FTP进入的用户的主目录,因此权限应该不是问题。 FTP在FileZilla中工作。
我检查了vsftp.conf并进行了local_enable=YES
更改
在具有Python 2.4.4的Debian4系统上(我无法对其进行升级),我将此代码与ftplib一起使用
>>> f = ftplib.FTP('address', 'user', 'password')
>>> f.cwd('/home/user/some/dir/')
'250 Directory successfully changed.'
>>> myfile = '/full/path/of/file.txt'
>>> o = open(myfile, 'rb')
>>> f.storbinary('STOR ' + myfile, o)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/ftplib.py", line 415, in storbinary
conn = self.transfercmd(cmd)
File "/usr/lib/python2.4/ftplib.py", line 345, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "/usr/lib/python2.4/ftplib.py", line 327, in ntransfercmd
resp = self.sendcmd(cmd)
File "/usr/lib/python2.4/ftplib.py", line 241, in sendcmd
return self.getresp()
File "/usr/lib/python2.4/ftplib.py", line 216, in getresp
raise error_perm, resp
ftplib.error_perm: 553 Could not create file.
任何想法为什么会失败?
您不是在写入主目录,而是在/full/path/of/file.txt
:
myfile = '/full/path/of/file.txt'
...
f.storbinary('STOR ' + myfile, o)
您仅需在STOR
命令中使用文件名(一旦“ cwd”已经是正确的目标路径):
f.cwd('/home/user/some/dir/')
f.storbinary('STOR file.txt', o)
或远程主机的正确绝对路径:
f.storbinary('STOR /home/user/some/dir/file.txt', o)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.