connect to a remote web server & upload data from Python using sshand scp

Tim Golden tim.golden at viacom-outdoor.co.uk
Mon Nov 7 03:54:53 EST 2005


[Swarna Pulavarty]

> I need to upload data ( text & image data ) to a remote web 
> server from python. I came to know that i could do it using 
> ssh and scp.....but am not sure of how to do it.

Well, the only difference between "server" and "web server" is that
the latter is guaranteed to be listening, probably on port 80, to
HTTP requests. If you want to avoid CGI (and, I assume, any other
web-interface means of transferring files) then you need to know
what *other* services the remote server is running. ssh/scp is one
possibility, FTP is another. There are others (rsync or WebDAV, for 
example). It all depends on what's on offer.

If you know the server in question will accept an ssh connection,
then one simple solution is to call scp (or pscp from the Putty 
suite if you're on Win32) from the command line to copy the files 
you want. If you want to do it from within Python, then you could 
use os.system or os.popen or one of its cousins to do the same. eg,

scp my_local_file.txt username at example.com:

If you only mean: "I know it's theoretically possible to copy
files to servers using ssh/scp but I don't about this particular
server" then you'll need to determine whether the server in question 
will accept ssh connections, and whether you have the right to create 
such a connection. Try the above, and see if it works.

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________



More information about the Python-list mailing list