Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Problem while copying a file from a remote filer

Reply
Thread Tools

Problem while copying a file from a remote filer

 
 
venutaurus539@gmail.com
Guest
Posts: n/a
 
      03-16-2009
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\\Folder0 02\
\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\\\\Folde r002\\\
\TextFile_06.txt'

Can some one please help me in this regard.

Thank you
Venu madhav
 
Reply With Quote
 
 
 
 
Chris Rebert
Guest
Posts: n/a
 
      03-16-2009
On Sun, Mar 15, 2009 at 10:24 PM, http://www.velocityreviews.com/forums/(E-Mail Removed)
<(E-Mail Removed)> wrote:
> 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\\Folder0 02\
> \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

--
I have a blog:
http://blog.rebertia.com
 
Reply With Quote
 
 
 
 
Jorgen Grahn
Guest
Posts: n/a
 
      03-17-2009
On Sun, 15 Mar 2009 22:47:54 -0700, Chris Rebert <(E-Mail Removed)> wrote:
> On Sun, Mar 15, 2009 at 10:24 PM, (E-Mail Removed)
> <(E-Mail Removed)> wrote:
>> 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\\Folder0 02\
>> \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.


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

/Jorgen

--
// Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.se> R'lyeh wgah'nagl fhtagn!
 
Reply With Quote
 
Tim Golden
Guest
Posts: n/a
 
      03-17-2009
Jorgen Grahn wrote:
> On Sun, 15 Mar 2009 22:47:54 -0700, Chris Rebert <(E-Mail Removed)> wrote:
>> On Sun, Mar 15, 2009 at 10:24 PM, (E-Mail Removed)
>> <(E-Mail Removed)> wrote:
>>> 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\\Folder0 02\
>>> \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.

>
> 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
 
Reply With Quote
 
Aahz
Guest
Posts: n/a
 
      03-25-2009
In article <(E-Mail Removed)>,
Chris Rebert <(E-Mail Removed)> wrote:
>On Sun, Mar 15, 2009 at 10:24 PM, (E-Mail Removed)
><(E-Mail Removed)> wrote:
>> 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 =3D ur"\\\\venuwin2008\\C\\4Folders\\Folder02\\Folder0 02\
>> \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.


Alternatively, and I think better practice, undouble the backslashes
instead of removing the 'r' prefix.
--
Aahz ((E-Mail Removed)) <*> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
e-mail og vedhæftede filer JYTTE GREGERSEN Computer Support 0 04-12-2005 11:10 AM
Remote Assistance fails to connect, remote remote host name could not be resolved Peter Sale Wireless Networking 1 12-11-2004 09:09 PM
Problems while copying an executable file with ANT Manish Hatwalne Java 1 07-26-2004 10:00 AM
Polarising filer - keep on or not? KirkoField Digital Photography 23 09-13-2003 06:59 PM
Mime::Parser::Filer problemo Chris Larsen Perl Misc 0 09-10-2003 08:18 PM



Advertisments