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

Ftplib ConnectionRefusedError: [Errno 111] Connection refused (python 3.5)

I have a script that should connect to a FTP from ftplib import FTP with FTP('IP') as ftp: ftp.login(user='my user', passwd='my password') ftp.cwd('/MY_DIR') ftp.dir() I have an error : ConnectionRefusedError: [Errno 111] Connection…
RonanT
  • 156
  • 2
  • 14
3
votes
2 answers

Connect to FTP server through http proxy

My code belove gives me the error: socket.gaierror: [Errno 11001] getaddrinfo failed when calling the method ftp.connect(). My question is: why can I connect to google.com but when connecting to an ftp server it gives me error? And how I can connect…
patski
  • 329
  • 6
  • 15
3
votes
1 answer

Python 3 ftplib error "Name or service not known"

I am trying to download a file from FTP server using ftplib library of Python 3. Here is the relevant code- ftp = ftplib.FTP("ftp://library.daisy.org:21/User_****/Wise & Otherwise-22.zip") ftp.login("xxxxx", "xxxxxxx")…
Sid24
  • 334
  • 3
  • 14
3
votes
1 answer

Python ftplib: How to correctly release connection object?

I have seen code like this (Python 3 code): import ftplib from contextlib import closing with closing(ftplib.FTP()) as ftp: Is the usage of the closing method necessary? In an interesting answer, we can read that in database connection objects the…
Jan Bodnar
  • 10,969
  • 6
  • 68
  • 77
3
votes
1 answer

Excluding an item in a for loop

I am trying to find the total size of a root directory on an FTP server. However, I do not have access to one of the directories in the root. I want to use this function to sum the sizes of the directories in the root: size = 0 for filename in…
3
votes
1 answer

Error after FTPS transfer finishes with Python ftplib

I'm trying to upload file into FTPS server (Wing FTP Server / Cerberus FTP Server 8) with following script. from ftplib import FTP_TLS ftps = FTP_TLS('192.168.133.69') ftps.login('1011', '7c52xK9') ftps.prot_p() filename = 'upload.pdf' myfile…
M.H.
  • 223
  • 3
  • 10
  • 23
3
votes
1 answer

How to move and replace files from FTP folder to another folder in same FTP

I am trying to move some XML files in an FTP location to another location in the same FTP. I tried with the following code, but it doesn't work. def ftpPush(filepathSource, filename, filepathDestination): try: ftp = FTP(ip, username,…
Dush
  • 51
  • 1
  • 1
  • 7
3
votes
0 answers

Using a Python script to establish FTP connection behind FTP proxy

Im trying to connect to an ftp server that is behind ftp proxy. The proxy server does not require username and password, the ftp server does. I have searched through several posts: Proxies in python How to use urllib2 to access ftp/http server…
Premysl Vorac
  • 473
  • 6
  • 16
3
votes
1 answer

How to check if FTP server offers TLS support in python?

How can I check if a FTP server allows for TLS when I connect using ftplib? I Found easy documentation on how to use TLS, but no solution on how to check for it. My script is supposed to connect either way, but use TLS if possible. So do I just…
JasonTS
  • 2,479
  • 4
  • 32
  • 48
3
votes
2 answers

Why is a success message considered an error in ftplib

import ftplib server = '192.168.1.109' user = 'bob' password = 'likes_sandwiches' box = ftplib.FTP(server) box.login(user, password) s = box.mkd('\\a\\this4\\') box.close() x = raw_input('done, eat sandwiches now') This returns: Traceback (most…
chazzycheese
  • 93
  • 1
  • 1
  • 4
3
votes
1 answer

Python FTPS upload error: 425 Unable to build data connection: Operation not permitted

I'm trying to use ftps to send a file to a FTP server. Login and changing directory work: import ftplib ftps = ftplib.FTP_TLS('host','user','pwd') ftps.set_pasv(True) ftps.prot_p() ftps.cwd('/target_directory') however when I try to upload my…
asfcm
  • 43
  • 1
  • 4
3
votes
2 answers

Python error handling for FTP hang / 421 timeout

I have a script (below) that pushes an html file to a server. It WORKS 95% of the time. However, about 5% of the time, the server fails and the attempt to connect hangs. It stalls for 15 minutes (900 seconds) and then fails. ftp = FTP('[FTP…
Maxim Lott
  • 368
  • 4
  • 15
3
votes
2 answers

How to catch FTP errors? e.g., socket.error: [Errno 10060]

I'm using the ftplib module to upload files: files = [ a.txt , b.txt , c.txt ] s = ftplib.FTP(ftp_server , ftp_user , ftp_pw) # Connect to FTP for i in range(len(files)): f = open(files[i], 'rb') stor = 'stor ' +…
Johnson
  • 31
  • 1
  • 2
3
votes
3 answers

Can I upload an object in memory to FTP using Python?

Here's what I'm doing now: mysock = urllib.urlopen('http://localhost/image.jpg') fileToSave = mysock.read() oFile = open(r"C:\image.jpg",'wb') oFile.write(fileToSave) oFile.close f=file('image.jpg','rb') ftp.storbinary('STOR…
fsckin
  • 215
  • 4
  • 8
3
votes
2 answers

Using ftplib for multithread uploads

I'm trying to do multithread uploads, but get errors. I guessed that maybe it's impossible to use multithreads with ftplib? Here comes my code: class myThread (threading.Thread): def __init__(self, threadID, src, counter, image_name): …
Arty
  • 5,923
  • 9
  • 39
  • 44