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

Does vsftpd supports mlsd command?

does vsftpd support mlsd command if it supports how can i enable it? or is there any other way to get list of file names and timestamp from a directory using python ftplib? tried nlst it only gives files names and for each file i have to sent MDTM…
chriscka
  • 157
  • 3
  • 12
2
votes
1 answer

Python stream from FTP server to Flask server for downloading

I have a Python Flask app that gets request to download a file from a remote FTP server. I have used BytesIO to save contents of the file downloaded from FTP server using retrbinary: import os from flask import Flask, request, send_file from ftplib…
Shod
  • 801
  • 3
  • 12
  • 33
2
votes
1 answer

Python: File download using ftplib hangs forever after file is successfully downloaded

I have been trying to troubleshoot an issue where in when we are downloading a file from ftp/ftps. File gets downloaded successfully but no operation is performed post file download completion. No error has occurred which could give more information…
Manish Mehra
  • 1,381
  • 1
  • 16
  • 24
2
votes
1 answer

Python3.6, ftp_tls and session reuse

So, I'm struggling trying to upload a file to a remote ftps server that requires session reuse. I must specify that even if I can connect to the server without problems via Filezilla, I get the error "unknown server certificate". This is my…
Ministry
  • 131
  • 4
  • 9
2
votes
1 answer

How do I scrape the text from a FTP server using Python?

I am looking to extract all the information from this page: Text data in FTP I understand that requests lib wouldn't work for ftp, so I have resorted to using ftplib. However, documentation seems to only explore the downloading of files in…
james
  • 51
  • 7
2
votes
2 answers

Fill variable with text of a .txt file at an FTP server in Python

I think my question sounds kinda stupid but I'm pretty new to python programming. I just want to have a text variable which gets a string from a .txt file at an FTP server. So in conclusion: There is a .txt File stored at an FTP server and I want…
user9066907
2
votes
1 answer

Check that FTP connection opened successfully and files have been uploaded to FTP in Python

I'm building a remote time-lapse camera that takes pictures every half hour and sends them via FTP to my server. A Raspberry Pi will control the camera, gather the files and send them over, via a Python script like so: while true …
mrc
  • 71
  • 1
  • 7
2
votes
1 answer

I got "ConnectionRefusedError" when I try to list an FTP server

I have a simple script to connect into a FTP server: from ftplib import FTP # Here is fine ftp = FTP(host='') ftp.login(user='', passwd='') ftp.cwd('/test/') # Here I got the error ftp.nlst() The connection it is just fine, the error is happening…
hsnbr-96
  • 21
  • 3
2
votes
2 answers

Python - get line count of a file via ftp

I am trying to use ftplib to count the number of lines in a file. This is what I have come up with so far. ftp = FTP('ftp2.xxx.yyy') ftp.login(user='xxx', passwd='yyy') count = 0 def countLines(s): nonlocal count count += 1 …
Dhanushka Amarakoon
  • 3,502
  • 5
  • 31
  • 43
2
votes
0 answers

python ftplib retrbinary æøå

I'm having a strange problem with Nordic characters 'æøå' when I download using ftplib. When using this part of the code: source_file = 'file_w_æøå.zip' ftp.retrbinary('RETR %s' % source_file, open(local_file, 'wb').write) I get this error: …
2
votes
1 answer

Use Python ftplib ftp.dir() or ftp.retrlines('LIST') to return only files containing a string

I am accessing a government website from Python 3.6 like this: from ftplib import FTP ftp = FTP("somedepartment.gov") ftp.login() >>> '230 Anonymous access granted, restrictions apply' filepath = "/path/to/ftp/folder/" ftp.cwd(filepath) >>> '250…
cardamom
  • 6,873
  • 11
  • 48
  • 102
2
votes
1 answer

Python FTP TLS not working

I'm trying to setup an FTP TLS transfer. I have scripts for strict FTP and for SFTP, but this is my first exposure to TLS. My basic script: import ftplib import ssl ctx = ssl._create_stdlib_context(ssl.PROTOCOL_TLSv1_2) ftps =…
Mike
  • 632
  • 2
  • 7
  • 17
2
votes
1 answer

Python ftplib: socket.gaierror: [Errno -3] Temporary failure in name resolution

I need to create simple code that will upload a .csv file to an FTP server. The code is below. import ftplib import os import sys sourceFilePath = '/home/user/dir/' filename = 'testing.csv' destinationDirectory = 'anotherDirectory' server =…
Glenn Minix
  • 51
  • 2
  • 8
2
votes
1 answer

Python FTP invalid argument

Python 3.6.1, Windows 10 x64 My goal with this script is to grab a .zip file from a FTP site and then put it into a local directory: from ftplib import FTP FTP_SERVER = 'ftp.name.com' def main(): ftp_conn = FTP(FTP_SERVER) …
Matt
  • 967
  • 2
  • 9
  • 23
2
votes
0 answers

Pyftpsync works only without TLS

Hi I'm using pyftpsync in order to upload new images (downloaded every day) in a online store skipping the existing ones. From the author site I'm using this code (with my personal data of course): from ftpsync.targets import FsTarget from…
LDV
  • 21
  • 2