Skip to content

Comment on Python Scripts for Downloading files via SFTP

Comments

Um, instead of using Python and the pexpect module, just use /usr/bin/expect by itself. The Expect language is very simple [1] and could cut this script down to less than 10 lines, if all you need to do is automate a couple transfers.

The paramiko module is the "right" way of doing this in Python, and probably only appropriate if you need to integrate SFTP transactions into a larger, longer-running application.

Edit: I might add the use of a password in a command line argument is not advisable because it will get logged everywhere and show up in things like top, etc. Probably better to hardcode it or put it in a 0600 file.

[1]: http://en.wikipedia.org/wiki/Expect (In fact, there is a complete example for automating SFTP right in the article).

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.