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
8
votes
1 answer

Change directory on server before uploading files with ftplib in Python

I have this code, but I can't figure out how to change directory on the server before uploading files. Can anyone help me out? import ftplib import os server = 'enter your servername here' username = 'root' password = 'passowrd' myFTP =…
user3551620
  • 169
  • 1
  • 5
  • 17
8
votes
1 answer

Set timeout for FTP connection in Python with ftplib

I am triying to set up the timeout of a FTP connection usign: class ftplib.FTP([host[, user[, passwd[, acct[, timeout]]]]]) Return a new instance of the FTP class. When host is given, the method call connect(host) is made. When user is given,…
David Comino
  • 97
  • 1
  • 1
  • 5
7
votes
2 answers

Creating list from retrlines in Python

How exactly would you create a list of the entries in an FTP directory? This is my code so far: import ftplib files = [] my_ftp = ftplib.FTP(HOST) my_ftp.login(USERNAME,PASSWORD) line =…
Abram I
  • 185
  • 2
  • 7
7
votes
2 answers

Getting the latest files from FTP folder (filename having spaces) in Python

I have a requirement where I have to pull the latest files from an FTP folder, the problem is that the filename is having spaces and the filename is having a specific pattern. Below is the code I have implemented: import sys from ftplib import…
Manas Jani
  • 699
  • 2
  • 11
  • 33
7
votes
1 answer

How to download big file in python via ftp (with monitoring & reconnect)?

UPDATE #1 The code in the question works pretty good for stable connection (like local network or intranet). UPDATE #2 I implemented the FTPClient class with ftplib which can: monitor a download progress reconnect in case of timeout or…
Roman Podlinov
  • 23,806
  • 7
  • 41
  • 60
7
votes
2 answers

Increment variable in callback during upload

I have the following python script for an upload that needs to show percent done. I am having trouble incrementing the variable that tracks the amount of data transferred. I get an UnboundLocalError: local variable 'intProgress' referenced before…
HelloW
  • 1,587
  • 2
  • 13
  • 24
7
votes
3 answers

FTPClient.listFiles not working

I am trying to list all the files under a specific directory in a ftp server. FTPFile[] subFiles = ftpClient.listFiles("directory"); Although the directory is a valid one , but the code gets stuck while calling listFiles , what may be the reason. ?…
Raja
  • 305
  • 2
  • 4
  • 14
7
votes
2 answers

Pass a value to the ftp.retrbinary callback

I'm writing a module that uses FTPLib to fetch files. I want to find a way to pass a value(in addition to the block) to the callback. Essentially, my callback is def handleDownload(block, fileToWrite): fileToWrite.write(block) And I need to…
Feasoron
  • 3,471
  • 3
  • 23
  • 34
6
votes
2 answers

ftplib python - returning error that login or password is incorrect

I am trying to use the python library "ftplib". I am able to connect to the FTP server on my MacBook just fine, using the finder settings under "Go --> Connect to Server..." When I use ftplib in a jupyter notebook it is returning the error…
6
votes
3 answers

Downloading files from ftp server using python but files not opening after downloading

I am using python to download files from a ftp server and i am able to download the files but when i open the files they seem to be corrupted or are not opening Files like songs or jpgs are working fine but documents,excel sheets,pdfs and text files…
user13208311
6
votes
2 answers

ftplib MLSD command gives 500 Unknown command

I have been using ls = f.mlsd() to get list of files and timestamp from ftp but it gives me ftplib.error_perm: 500 Unknown command Is there any problem with ftp server? do i need to install anything on the server to get this command working
chriscka
  • 157
  • 3
  • 12
6
votes
2 answers

Read a CSV file stored in a FTP in Python

I have connected to a FTP and the connection is successful. import ftplib ftp = ftplib.FTP('***', '****','****') listoffiles = ftp.dir() print (listoffiles) I have a few CSV files in this FTP and a few folders which contain some more CSV's. I need…
Harikrishna
  • 1,100
  • 5
  • 13
  • 30
6
votes
3 answers

Getting a OSError when trying to LIST ftp directories in Python

Using Python 3.6.3. I am connecting to an FTP to using ftplib via FTP_TLS. ftps = ftplib.FTP_TLS('example.com', timeout=5) # TLS is more secure than SSL ftps.ssl_version = ssl.PROTOCOL_TLS # login before securing control…
Pipupnipup
  • 163
  • 2
  • 8
6
votes
3 answers

connecting ftp server using python

I try to connect to an ftp server in my phone using python code and I get an error. Code import ftplib server = ftplib.FTP() server.connect('192.168.135.101', 5556) server.login('svgn','123456') print (server.dir()) Error C:\Python27\python.exe …
Ali Şıvgın
  • 61
  • 1
  • 2
  • 7
6
votes
2 answers

Change permissions via ftp in python

I'm using python with ftplib to upload images to a folder on my raspberryPi located in /var/www. Everything is working fine except that uploaded files have 600 permissions and I need 644 for them. Which is the best way to do this? I'm searching for…
1 2
3
45 46