On Feb 22, 9:02 pm, "venutaurus...@gmail.com" <venutaurus...@gmail.com> wrote: > On Feb 23, 9:25 am, MRAB <goo...@mrabarnett.plus.com> wrote: > > > > > venutaurus...@gmail.com wrote: > > > Hello all, > > > I am writing an application where I need to open a shared > > > file on a remote machine using python script. I tried using the > > > following function: > > > > f = urllib.open("\\remote_machine\\folder1\\file1.doc") > > > > I also tried using > > > > class urllib.FancyURLopener(...) > > > > but didn't work. Can some one help me in this regard. > > > What do you mean by "remote machine"? Do you mean you want to open a > > file that's in a shared folder on a machine that's on the same local > > network? > > > If it's meant to be a Windows filepath then it should be: > > > f = open(r"\\remote_machine\folder1\file1.doc") > > > (If the file is a Microsoft Word document file, then you won't probably > > be able to make much sense of its contents using open().) > > Thanks to all for your brisk replies: > > Yes, my aim is to open a file from another machine in the same > LAN. It also worked using > > >>f = urllib.urlopen("\\\remote_machine\\folder\\file.doc") > > But now I also have to copy the same file to the local machine > in Python. Do I need to follow any protocols for this? > > Thank you, > Venu.
the copy in shutil will work just fine. import shutil shutil.copy(remotepath,localpath) -- http://mail.python.org/mailman/listinfo/python-list