Copying files to multiple comp's on a lan

Henrik Berg Nielsen hbn at imada.sdu.dk
Sun Jun 3 11:11:09 EDT 2001


Hi again,

I got the win32all as Mark suggested and everything works like a charm now!

Just one more question:
Is it possible to

cmd_string = "copy %s %s" % ("\\Machine1\C\temp\foo.txt",
"\\Machine2\C\temp")
os.system(cmd_string)

when I am sitting and issuing the command from Machine0?
I'd like to design the script so that it copies the file to/from multiple
comps at one time, not just from the source to all the other machines one at
a time seperately, but more like:

Step 1:
copy from comp0 to comp1

Step2:
copy from comp0 to comp2
copy from comp1 to comp3

Step3:
copy from comp0 to comp4
copy from comp1 to comp5
copy from comp2 to comp6
copy from comp3 to comp7

and so on and so on...

where comp0 would be the initial source

Is this possible at all? Doing it this way would make better use of the
network, its switched, so collisions should be a problem, although the
traffic will be immense if I'm disting a 700 MB file.

All for now,

Henrik Berg Nielsen
"Mark Hammond" <MarkH at ActiveState.com> wrote in message
news:3B198B17.3060409 at ActiveState.com...
> Henrik Berg Nielsen wrote:
>
> > programming). So far I haven't been able to access file on the remote
> > machines via the open() method. What should I write if I wanted to
access
> > the file called "foo.txt" located in the "temp" folder on the C drive of
the
> > machine named "Orion"?
>
>
> In general, you need to know how the C:\TEMP directory is "shared" by
> the machine "Orion".  If you have administrator rights, you will
> probably find that:
>     r"\\Orion\c$\temp"
>
> will work.  In general, whatever string you can pass to the command
> prompt's "dir" command to see the file can be passed to open().
> Remember that Python sometimes requires backslashes to be doubled -
> hence my r"..." notation above - it uses raw strings which do generally
> not need slashes doubled.  ie, without raw strings, you would need to
> say "\\\\Orion\\c$\\temp"
>
> If you don't have access to the 'C$' share, then you need to investigate
> the specific settings for the specific server.  There are some obscure
> ways to determine this stuff programatically, but let's get the simple
> things working first :)
>
>
> > I like the approach more where I let os.system() do the copying for me,
but
> > it really doesn't work all that good if I can't assemble the proper
network
> > paths.
>
>
> Experiment with assembling the paths from the command prompt.
>
> > On a side note; what does os.sytem() do specifically?
>
>
> Executes the command - almost as if you typed the command from a DOS
prompt.
>
> > Also I tried "import win32api, win32file, win32net" and it can't find
> > neither of them, should I install these seperately or what? (plz don't
laugh
> > :))
>
>
> You probably need win32all from
>
http://aspn.activestate.com/ASPN/Downloads/ActivePython/Extensions/Win32all
>
> If you installed ActivePython itself, they should all be there already.
>
> Mark.
>





More information about the Python-list mailing list