Python: what's the best way to copy files on a LAN?

Chris Watson chris at voodooland.net
Wed Jan 24 09:52:38 EST 2001


> I mean security-wise. I'd like to use FTPLIB but am hesitant about the
> security issues involved in using that plain-text protocol.

scp. Without a doubt.

#!/usr/local/bin/python

import os

host = raw_input("Enter a hostname: ");

os.spawnv(os.P_WAIT, '/usr/bin/scp', ('-v', 'username@%s:/home/username/TESTFILE' % host, '/tmp/TESTFILE'))

os.system("pico /tmp/TESTFILE")

os.spawnv(os.P_WAIT, '/usr/local/bin/rsync', ('rsync', '-v', '-p', '-e', 'ssh', '/tmp/TESTFILE', 'username@%s:/home/username/TESTFILE' % host))

This will fetch a file with scp from a remote host over to the localhost,
then rsync it back after a change was made with pico. But your only
interested in the scp line. Works great, even with RSA keys.

--
=============================================================================
-Chris Watson         (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek 
Work:              scanner at jurai.net | Open Systems Inc., Wellington, Kansas
Home:  scanner at deceptively.shady.org | http://open-systems.net
=============================================================================
WINDOWS: "Where do you want to go today?"
LINUX: "Where do you want to go tomorrow?"
BSD: "Are you guys coming or what?"
=============================================================================
GNU = Gnu's Non-portable & Unstable
irc.openprojects.net #FreeBSD -Join the revolution!
ICQ: 20016186





More information about the Python-list mailing list