Copying files to multiple comp's on a lan

Mark Hammond MarkH at ActiveState.com
Sat Jun 2 20:53:16 EDT 2001


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