- 论坛徽章:
- 0
|
写了一个python脚本,将windows下的一个文件上传到vsftp上(1台linux系统),代码如下 :- from ftplib import FTP
- def ftpconnect():
- ftp_server = '192.168.1.1'
- username = 'user'
- password = 'Tes'
- ftp=FTP()
- ftp.set_debuglevel(2)
- ftp.connect(ftp_server,21)
- ftp.login(username,password)
- ftp.set_pasv(1)
- print ftp.pwd()
- remotepath =r‘filename'
- bufsize = 1024
- localpath =r'e:\i\filename'
- fp = open(localpath,'rb')
- print dir(ftp)
- ftp.storbinary('STOR '+ remotepath ,fp,bufsize)
- fp.close()
- ftp.quit()
- if __name__ == '__main__':
- ftpconnect()
复制代码 用户可以登录,可以列出目录下文件,但上传会报如下错误:
*get* '553 Could not create file.\r\n'
*resp* '553 Could not create file.'
Traceback (most recent call last):
File "E:/project1/auto_back_ftpuser.py", line 25, in <module>
ftpconnect()
File "E:/project1/auto_back_ftpuser.py", line 20, in ftpconnect
ftp.storbinary('STOR '+ remotepath ,fp,bufsize)
File "C:\Python27\lib\ftplib.py", line 471, in storbinary
conn = self.transfercmd(cmd, rest)
File "C:\Python27\lib\ftplib.py", line 376, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "C:\Python27\lib\ftplib.py", line 339, in ntransfercmd
resp = self.sendcmd(cmd)
File "C:\Python27\lib\ftplib.py", line 249, in sendcmd
return self.getresp()
File "C:\Python27\lib\ftplib.py", line 224, in getresp
raise error_perm, resp
ftplib.error_perm: 553 Could not create file.
vsftp目录的用户目录已经改成777了,不行,selinux也关了,也不行,请大牛帮忙看看吧 |
|