Questions tagged [ftplib]

ftplib — FTP protocol client under Python programming language

ftplib is a python module which defines the class FTP and a few related items.

The FTP class implements the client side of the FTP protocol. You can use this to write Python programs that perform a variety of automated FTP jobs, such as mirroring other ftp servers. It is also used by the module urllib.request to handle URLs that use FTP. For more information on FTP (File Transfer Protocol), see Internet RFC 959.

Read more about ftplib at python docs..

681 questions
6
votes
2 answers

List all the files in all subdirectories from an FTP using Python

I'm new to Python and I'm trying to list all the files in all the sub-directories from an FTP. The FTP, as usual, is in this format. A B C Subdirectories : AA BB CC I could list the directories ['A', 'B', 'C'] using ftp.nlist(). I'd like…
abn
  • 1,353
  • 4
  • 28
  • 58
6
votes
2 answers

correctly parsing a CSV file from an FTP server with app engine

I'm trying to read a CSV file from an FTP server and parse it on app engine. I can access the file and read it to StringIO but when I try to loop over the files lines it just loops over every character instead of lines. Not sure what I'm doing wrong…
aschmid00
  • 7,038
  • 2
  • 47
  • 66
6
votes
8 answers

How do I parse a listing of files to get just the filenames in Python?

So lets say I'm using Python's ftplib to retrieve a list of log files from an FTP server. How would I parse that list of files to get just the file names (the last column) inside a list? See the link above for example output.
Redwood
  • 66,744
  • 41
  • 126
  • 187
6
votes
0 answers

ftplib vs urllib2?

I can't figure out how to pick between ftplib and urllib2 for downloading a file over FTP. As far as I can tell, they work comparably well, and most recommendations just seem to presume one or the other without listing pros/cons. Furthermore, there…
amos
  • 5,092
  • 4
  • 34
  • 43
5
votes
1 answer

Getting EOFError along with exceptions when using ftplib

I'm looking into using ftplib (and possibly ftputil) for doing some automated FTP file syncing. I have a couple of servers to test this against at the moment, but, whilst I'm having a successful conversation with both servers, I get EOFError-s with…
bdeniker
  • 995
  • 1
  • 9
  • 21
5
votes
1 answer

How to check for change in the directory at FTP server?

I want to get the file from FTP server to local as soon as new file is added in directory on FTP. I know changes in the directory at local machine can be seen using watchdog observer. But I want to check for the change in the directory (addition of…
Aayan Arora
  • 77
  • 2
  • 7
5
votes
1 answer

Python ftp.nlst() return empty list when where are (sub)directories on the server

My application needs to download all the directories from a remote FTP, I'm testing for the first time the Python's ftplib. When I try to list all the directories in the remote FTP with the command ftp.nlst() it return an empty list. I know for sure…
Gargantua
  • 420
  • 2
  • 5
  • 17
5
votes
2 answers

when using ftplib in python

Here is the relevant code that's causing the Error. ftp = ftplib.FTP('server') ftp.login(r'user', r'pass') #change directories to the "incoming" folder ftp.cwd('incoming') fileObj = open(fromDirectory + os.sep + f, 'rb') #push the file try: …
Ramy
  • 20,541
  • 41
  • 103
  • 153
5
votes
1 answer

Getting "500 Unknown command" when uploading a file to FTP in Python with FTP.storbinary

I am trying to upload a file to FTP. I am trying to upload a file to /public_html on files.000webhost.com but I keep getting ftplib.error_perm: 500 Unknown command My code is below: import ftplib session =…
user8528838
5
votes
1 answer

Connecting to 'Explicit FTP over TLS' in Python (??)

I cannot figure out how to see the file contents of an FTP site using ftplib. I can connect to the FTP site using WinSCP just fine, and see the 6 files in the root directory. In Python 3.4, I am using the following code: from ftplib import…
lukehawk
  • 1,423
  • 3
  • 22
  • 48
5
votes
1 answer

How to install python ftplib in windows?

I want to write some ftp program using python. Please help me to install "ftplib" in windows 7. I have tried to install it but not succeed.
user3872486
  • 97
  • 1
  • 2
  • 10
5
votes
3 answers

Download files from an FTP server containing given string using Python

I'm trying to download a large number of files that all share a common string (DEM) from an FTP sever. These files are nested inside multiple directories. For example, Adair/DEM* and Adams/DEM* The FTP sever is located here:…
geos
  • 55
  • 1
  • 4
5
votes
3 answers

Python's ftplib with tqdm

I have a console script which uses ftplib as a backend to get a number of files from an ftp server. I would like to use tqdm to give the user some feedback provided they have a "verbose" switch on. This must be optional as some users might use the…
Sardathrion - against SE abuse
  • 17,269
  • 27
  • 101
  • 156
5
votes
3 answers

Error for ftplib.cwd: UnicodeEncodeError: 'latin-1' codec can't encode characters

There are many posts about 'latin-1' codec , however those answers can't solve my problem, maybe it's my question, I am just a rookie to learn Python, somewhat. When I used cwd(dirname) to change directory of FTP site, the unicodeerror occurred.…
zhigang
  • 66
  • 1
  • 3
5
votes
1 answer

error_perm: 500 Unknown command Python ftplib storbinary

I'm trying to upload a file using ftplib in Python. ftp = FTP('...') ftp.login('user', 'pass') f = open(filename) ftp.storbinary(filename, f) f.close() ftp.quit() storbinary is returning error_perm: 500 Unknown command., which…
FranGoitia
  • 1,965
  • 3
  • 30
  • 49