How to copy a file from one machine to another machine

Steve Holden steve at holdenweb.com
Wed Sep 21 06:29:14 EDT 2005


Nico Grubert wrote:
> Hi there,
> 
> I would like to copy a file from one machine (machine #01) to another 
> (machine #02).
> 
> machine #01: Suse Linux 9.2, Samba 3, Python 2.3.5
> machine #02: Windows Machine, Destination Dir: <Share>\temp\files\
> 
> Both machines are in one network so they can communicate each other. In 
> order to be able to write a file in the directory on Machine #02 I need 
> to be the user "myadmin".
> 
> In a short Python program I create the source file on Machine #01 like this:
> 
> filecontent = 'This is just a test...'
> # my own helper method to generate a unique filename
> filename = createUniqueFilename()
> f = open('/var/files/' + filename, 'w')
> f.write(filecontent)
> f.close()
> 
> 
> Every time a new source file has been created it needs to be copied or 
> moved from machine #01 to machine #02.
> Are there Python modules which help me doing this job? Any examples how 
> to do that would be very helpful.
> 
This isn't really a Python question, as this problem would exist 
irrespective of the language you are using.

One possibility would be to run Samba (www.smaba.org) on the Linux 
machine so it offered a share to the Windows machine. Then you could 
just write to a UNC path (\\server\path\to\file) from Windows and have 
the file appear on the Linux machine.

Another way would be to use CIFS client on Linux to access the share 
from the Windows machine.

There are many other file sharing solutions, and you can of course also 
consider using FTP to send the file to the Linux server.

Some ideas to start with, anyway.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                          www.pycon.org




More information about the Python-list mailing list