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

Copy file from FTP to S3 bucket using boto3 and ftplib is failing with "500 Syntax error, command unrecognized"

I need to send data from an FTP server into an S3 bucket without saving the file to my local drive. On the internet, I found that we can use io.BytesIO() as buffer. But my code fails with: error_perm: 500 Syntax error, command unrecognized. The…
Dimas Aps
  • 71
  • 8
2
votes
1 answer

Python ftplib pwd() returns an empty string

I'm writing a Python program centered around transferring files from a PC to a target device. So far I've used the ftplib package for all the other functions in the program. I've encountered a problem that didn't happen in any of the other devices…
Ben Pinhas
  • 63
  • 6
2
votes
1 answer

Deleting all files in FTP folder in Python fails with "500 Invalid command: "MLSD""

I'm trying to delete a folder using ftplib with Python. I've tried ftp.delete, but it only accepts files I've tried ftp.rmd but that only works with empty folders. Tried a recursion function I found online: def remove_ftp_dir(ftp, path): for…
Ben Pinhas
  • 63
  • 6
2
votes
1 answer

How can I resume interrupted FTP upload in Python

I need to manually interrupt am FTP upload and then test that I can resume the upload. I am using Python's ftplib module. I have tried below code: # Consider I have logged in using valid ftp user # File is of 20 MB counter = 0 file_name =…
Luffy
  • 83
  • 1
  • 10
2
votes
1 answer

Identify new files in FTP and write them to AWS S3

I'm currently using ftplib in Python to get some files and write them to S3. The approach I'm using is to use with open as shown below: with open('file-name', 'wb') as fp: ftp.retrbinary('filename', fp.write) to download files from FTP…
wawawa
  • 2,835
  • 6
  • 44
  • 105
2
votes
3 answers

To read the latest csv file automatically from an FTP directory on Pandas

I am a beginner in Python programming but I believe the problem I am trying to solve might not be a big one. So I am working on a program to present the last row on the latest csv file to the end user. At the moment I am copying and pasting the…
Nishant
  • 21
  • 1
2
votes
1 answer

Python - Write in text mode to file opened in binary mode

I am asking this out of curiosity. What I am doing: creating a temp file writing data from a Pandas dataframe to it by using to_csv() pushing the file to a FTP server As the tempfile is opened in binary mode by default but the to_csv() method by…
DR318
  • 33
  • 5
2
votes
2 answers

Recursive file list with FTP

I know how to list all files in a directory from a FTP server: import ftplib ftp = ftplib.FTP() ftp.connect("192.168.1.18", port=2240) ftp.login() ftp.cwd('path/to') for f in ftp.mlsd(): print(f) But what's the best way to obtain a recursive…
Basj
  • 41,386
  • 99
  • 383
  • 673
2
votes
1 answer

Trying to download a series of archives from NCBI ftp using python ftplib but ftplib freezes at end of long file transfer

I'm trying to download the nr blastdabase form NCBIs ftp site (ftp://ftp.ncbi.nlm.nih.gov/blast/db). One of the files is quite large (16GB) and takes some time to download. At the end of downloading this file the program just hangs, it does not move…
2
votes
2 answers

Access FTP URL with ftplib

I am using python in Windows with ftplib to access a folder at ftp5.xyz.eu. The folder is 'baz' in ftp5.xyz.eu in the folder 'foo bar'. So : ftp5.xyz.eu/foo bar/baz I connect successfully at ftp5.xyz.eu but when i write the whole path to the…
Voicu Mirel
  • 113
  • 6
2
votes
1 answer

ftplib.error_perm: 550 when trying to change directory

I'm trying to work with provided CSV files on an FTP. I can log onto the FTP Server and when I: ftp = FTP(server); ftp.login(user = 'user', passwd = '***'); print(ftp.dir()); it works fine. But I can't change the directory by ftp.cwd('/CSV') It…
Kai Stredder
  • 35
  • 1
  • 3
2
votes
2 answers

Getting "Operation not permitted" or "Not a regular file" when uploading file with Python ftplib

I'm want to upload a file using Python to an rental FTP server (coreserver). The code is like this # -*- coding: utf-8 -*- import ftplib def ftp_upload(hostname, username, password, upload_src_path, upload_dst_path): ftp = ftplib.FTP(hostname) …
Kiyo4810
  • 21
  • 2
2
votes
1 answer

Cant connect to local pyftpdlib FTP server: [WinError 10061] No connection could be made

I am trying to upload/download file to local FTP server, but it gives me the error mentioned in title. For server I am using pyftpdlib: import os from pyftpdlib.authorizers import DummyAuthorizer from pyftpdlib.handlers import FTPHandler from…
Ach113
  • 1,775
  • 3
  • 18
  • 40
2
votes
1 answer

File created and uploaded to FTP in Python ftplib is empty

I am trying to make a simple server-client interaction with Python using json. But now I have a problem, my .json file does upload, but then on the server-side it is empty. Can you help me? import json import urllib.request import os import…
Bluppie05
  • 113
  • 8
2
votes
1 answer

How to upload data from memory via FTP in Python 3?

I want to upload various data from memory (contents of arrays, static html-code, ...) to a webserver via FTP. This works for just one basic string 'Hello World': from ftplib import FTP import io ... bio = io.BytesIO(b'Hello…
etechniker
  • 23
  • 3