[Tutor] Copying file to multiple machines.
Scott Widney
SWidney@ci.las-vegas.nv.us
Wed, 19 Sep 2001 14:50:26 -0700
> > I am new to python and am trying to copy a file from my
> > machine to multiple machines on a network (98 machines)
>
> You have W2K they have Win98?
>
> Do they have sharing turned on for the folders you want
> to copy to? If so you can use WSH to access the shared drives.
> Hammonds book shows an example of this. Look under WSH.
>
> However for this a simple CMD file would maybe be easier...
> Although Python might make it easier to discover each
> machine in the network before running the scroipt with the
> machine name as a parameter - a hybrid approach?
>
> Just some random thoughts.
If this is a one time deal, take the quick and simple route. You may end up
spending a lot of time researching and fine-tuning (not to mention adding
error-checking and logging). It's only worth the effort if you're going to
be doing this frequently.
The copying process will be simple enough once you have a list of machine
names over which to iterate. From a command prompt, you could redirect NET
VIEW to a file to get a list of machine names (manual cleanup required).
i.e. C:\>NET VIEW > MACHINES.TXT
To get the list Pythonically, you need ActivePython or the win32 extensions.
Then you'd use the win32net module's NetServerEnum() function to get the
names (programmatic cleanup required).
Hint: look in \Python\win32\Lib\win32netcon.py for the SV_TYPE_* values.
The shutil module has the copy() function that you'll want to use.