Copying files to multiple comp's on a lan

Chad Everett chat at linuxsupreme.homeip.net
Fri Jun 1 21:17:47 EDT 2001


On 1 Jun 2001 17:06:02 -0700, Jeff Shannon <jeff at ccvcorp.com> wrote:
>Hm, I'd probably use the os.system() call in preference to reading the 
>source and then creating new destination files, as D-Man's example does, 
>though the choice is probably trivial and entirely personal opinion.
>
>Example:
>
>---------------------
> import sys
> import os
> 
> # note Win32 uses \, not /  :)
> machines = [ "\\Mach1\C" , "\\Mach2\C" , "\\Mach3\C" ]
> 
> source_file_path = sys.argv[1]
> dest_path = sys.argv[2]
>
> for machine in machines:
>     # always use os.path.join() when building paths....
>     dest_fullpath = os.path.join(machine, dest_path) 
>     cmd_string = "copy %s %s" % (source_file_path, dest_fullpath)
>     os.system(cmd_string)
>
>---------------------
>
>You'd probably be better off if the machine/drive specs were built using
>the functions in os.path as well, but that's a minor detail.  I'd also, if
>I were writing this script for my own use, add a few print statements to 
>report on the current status, etc.... I'd also probably put the os.system()
>call within a try/except block, just in case.  And of course, this all 
>presumes that you do have write permission on all of these machines.  :)
>
>Jeff Shannon
>Technician/Programmer
>Credit International

It also presumes you're using Microsoft networking.




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



More information about the Python-list mailing list