FTP not downloading files but showing success - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: FTP not downloading files but showing success (/thread-1783.html) |
FTP not downloading files but showing success - python_lover - Jan-25-2017 Hi, I am new to python.....but have good Unix background. I was trying to have ftp download a file from remote server to my local unix server..... import ftplib ftp = ftplib.FTP(some remote server) ftp.login(uid,pass) ftp.pwd() ftp.cwd('/var/tmp') ftp.dir() ftp.retrlines('RETR somefile') Now what is happening is, I am getting all the messages for dir listing, path etc... and finally am getting "226 file transfer successful". But the directory where I ran the above code when checked, I didnt find the file downloaded there. Not sure what I have missed. When I tried to check similar code on the net, found that some guys are opening a local file in write mode and downloading the contents of remote file in it. I find this unnecessary as why cant we just get the file in its entirety as we do in unix ftp session. Why should I be required to create a file at local server in write mode and then dump contents from remote file in it? Please let me know if I have understood this correctly and please help. Thanks, PL RE: FTP not downloading files but showing success - buran - Jan-25-2017 looking at docs, I think you do need to open a local file to write (i.e. the callback). There is example with ftp.retrbinary and for retrline the default callback is stdout Quote:FTP.retrbinary(command, callback[, maxblocksize[, rest]]) RE: FTP not downloading files but showing success - python_lover - Jan-25-2017 Hmm thought so, Thanks dude! |