I created a python FTP client and a server. I used python pftpdlib
for the server and ftplib
for client. I was able to start the server successfully and connect to the server through the python client. But, when I need to store a file in the server, I get following error.
File "/usr/lib/python2.7/ftplib.py", line 471, in storbinary
conn = self.transfercmd(cmd, rest)
File "/usr/lib/python2.7/ftplib.py", line 376, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "/usr/lib/python2.7/ftplib.py", line 339, in ntransfercmd
resp = self.sendcmd(cmd)
File "/usr/lib/python2.7/ftplib.py", line 249, in sendcmd
return self.getresp()
File "/usr/lib/python2.7/ftplib.py", line 224, in getresp
raise error_perm, resp
ftplib.error_perm: 550 Not enough privileges.
Following is the source of my server
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
authorizer = DummyAuthorizer()
authorizer.add_anonymous("/home/deepal/anonymous")
handler = FTPHandler
handler.authorizer = authorizer
handler.banner = "Server Ready.."
address = ("",21)
server = FTPServer(address, handler)
server.max_cons = 10
server.serve_forever()
And following is the client.
from ftplib import FTP
hostname = sys.argv[2]
ftp = FTP(hostname)
ftp.login()
filepath = "/home/deepal/Desktop/infile"
localfile = open(filepath,"rb")
ftp.storbinary("STOR "+str(os.path.basename),localfile)
I need to transfer a file to the server anonymously. Can anybody help me pointing what is wrong with my code which gives above error? Isn't it possible to store files anonymously in this way?
Thank you.