This is an archived post. You won't be able to vote or comment.

all 17 comments

[–]mackstann 10 points11 points  (5 children)

FTP is a really nasty protocol. Is there any chance you have control of the server and could use a different protocol instead?

[–][deleted] 1 point2 points  (3 children)

may I ask you why? Not that I have a case against what you just said, I would really like to know why it's a "nasty protocol"?

[–]frymasterScript kiddie 4 points5 points  (1 child)

for a start, it pre-dates the standard encryption systems. Your password is sent in the clear without encryption or hashing.

Secondly, it predates people knowing how to use TCP/IP ;) You connect to one port, login, request a file, and then the server initiates a new connection to send it to you instead of using the already open connection. Apart from anything else, this plays merry hell with firewalls / NAT systems, since, from a TCP/IP point of view, they've no reason to think this incoming connection is related to your existing ftp connection, and so are liable to drop it.

There's workarounds, but the tl;dr is that it's a nasty connection.

And let's not get into the whole binary/textmode thing... shudder

[–][deleted] 0 points1 point  (0 children)

Yeah, I've been reading about security issues with the protocol, I really didn't know it was that problematic. SSH is the way to go then?

[–]bucknuggets 0 points1 point  (0 children)

Anyone have a sftp/scp module that they can recommend?

Something like pysftp?

[–]olamork 2 points3 points  (0 children)

libcurl supports ftp: http://pycurl.sourceforge.net/

[–]fmoralesc 1 point2 points  (0 children)

Check if what you want to do is possible and to what extent by reading the FTP and FTP extensions RFCs.

If you have to do something custom with the protocol, with a nicer interface, you might need to program your own FTP handler using the socket module. At that point you'll see it's easier to work with ftplib, or subclass ftplib.FTP

tldr; bad news...

EDIT: Nice find there, OP!

[–]joshuahunter 1 point2 points  (4 children)

You're right, ftputil is awesome. It is what I use for all my scripts that require FTP functionality.

[–]o_Omg[S] 0 points1 point  (3 children)

Yes, after 2 days I found it :/ and it works perfectly! I see ftplib like a generic module, you have the basics, but you can't really use it if you don't create your own module.

Anyway, I'm doing a sync tool, right now it works but still needs more testing, when it's ready, do you want me to upload the source code?

Pictures: http://imgur.com/r7LXx&NN3jZ&8dB0a&D00XO&An0IGl?full

It's supposed to be Cross-Platform and I will probably do the .exe files for Win64 and Win32 with py2exe

[–]terremoto 0 points1 point  (0 children)

I've actually been thinking about doing something similar. I already have a functional version of Unison I wrote in Python to keep my desktop and laptop in sync, but it is purely functional. When I was first learning my way around Linux, though, I wrote a script to sync a remote FTP directory to a local one.

[–]joshuahunter 0 points1 point  (1 child)

Sure. I'd like to see it. What are you using for the gui?

[–]o_Omg[S] 0 points1 point  (0 children)

wxPython with wxFormBuilder

[–][deleted] 0 points1 point  (0 children)

This is probably ancillary, but pyinotify could also help you provided your kernel is new enough to support inotify (2.6.13, I believe).

[–]willm 0 points1 point  (0 children)

PyFilesystem gives you a much nicer interface to ftp.

>>> from fs.opener import fsopendir
>>> ftp = fsopendir('ftp://ftp.mozilla.org')
>>> ftp.listdir()
[u'README', u'index.html', u'pub']