Problem while copying a file from a remote filer

V

venutaurus539

Hi all,
I have to write an application which does a move and copy of a
file from a remote machine to the local machine. I tried something
like:

file = ur"\\\\venuwin2008\\C\\4Folders\\Folder02\\Folder002\
\TextFile_06.txt"
dest = "C:\\test"
shutil.copy(file,dest)

But it is throwing an error:

Traceback (most recent call last):
File "E:\venu\Testing Team\test.py", line 22, in <module>
shutil.copy(file,dest)
File "C:\Python26\lib\shutil.py", line 88, in copy
copyfile(src, dst)
File "C:\Python26\lib\shutil.py", line 52, in copyfile
fsrc = open(src, 'rb')
IOError: [Errno 22] invalid mode ('rb') or filename: u'\\\\\\\
\venuwin2008\\\\C\\\\4Folders\\\\Folder02\\\\Folder002\\\
\TextFile_06.txt'

Can some one please help me in this regard.

Thank you
Venu madhav
 
C

Chris Rebert

Hi all,
     I have to write an application which does a move and copy of a
file from a remote machine to the local machine. I tried something
like:

file = ur"\\\\venuwin2008\\C\\4Folders\\Folder02\\Folder002\
\TextFile_06.txt"

The 'r' prefix on the string makes it a raw string, meaning you don't
have do double-up the backslashes, but you did so anyway, so your path
has many extra backslashes, making it invalid. Dropping the 'r' prefix
should fix the problem.

Cheers,
Chris
 
J

Jorgen Grahn

The 'r' prefix on the string makes it a raw string, meaning you don't
have do double-up the backslashes, but you did so anyway, so your path
has many extra backslashes, making it invalid. Dropping the 'r' prefix
should fix the problem.

Also, the file isn't really remote if you can use the normal local
file system calls to read it.

/Jorgen
 
T

Tim Golden

Jorgen said:
Also, the file isn't really remote if you can use the normal local
file system calls to read it.

That's a slightly strange position to take.
When *is* it remote, then?

TJG
 
A

Aahz

The 'r' prefix on the string makes it a raw string, meaning you don't
have do double-up the backslashes, but you did so anyway, so your path
has many extra backslashes, making it invalid. Dropping the 'r' prefix
should fix the problem.

Alternatively, and I think better practice, undouble the backslashes
instead of removing the 'r' prefix.
--
Aahz ([email protected]) <*> http://www.pythoncraft.com/

"At Resolver we've found it useful to short-circuit any doubt and just
refer to comments in code as 'lies'. :)"
--Michael Foord paraphrases Christian Muirhead on python-dev, 2009-3-22
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top