Problem while copying a file from a remote filer

Discussion in 'Python' started by venutaurus539@gmail.com, Mar 16, 2009.

  1. Guest

    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
    , Mar 16, 2009
    #1
    1. Advertising

  2. Chris Rebert Guest

    On Sun, Mar 15, 2009 at 10:24 PM,
    <> 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\\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

    --
    I have a blog:
    http://blog.rebertia.com
    Chris Rebert, Mar 16, 2009
    #2
    1. Advertising

  3. Jorgen Grahn Guest

    On Sun, 15 Mar 2009 22:47:54 -0700, Chris Rebert <> wrote:
    > On Sun, Mar 15, 2009 at 10:24 PM,
    > <> 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\\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.


    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!
    Jorgen Grahn, Mar 17, 2009
    #3
  4. Tim Golden Guest

    Jorgen Grahn wrote:
    > On Sun, 15 Mar 2009 22:47:54 -0700, Chris Rebert <> wrote:
    >> On Sun, Mar 15, 2009 at 10:24 PM,
    >> <> 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\\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.

    >
    > 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
    Tim Golden, Mar 17, 2009
    #4
  5. Aahz Guest

    In article <>,
    Chris Rebert <> wrote:
    >On Sun, Mar 15, 2009 at 10:24 PM,
    ><> 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\\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.


    Alternatively, and I think better practice, undouble the backslashes
    instead of removing the 'r' prefix.
    --
    Aahz () <*> 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
    Aahz, Mar 25, 2009
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Manish Hatwalne
    Replies:
    1
    Views:
    1,153
    JavaJug
    Jul 26, 2004
  2. Replies:
    1
    Views:
    583
    Oliver Wong
    Jul 13, 2006
  3. aidy

    Lock file while copying

    aidy, Aug 24, 2010, in forum: Ruby
    Replies:
    1
    Views:
    96
    Brian Candler
    Aug 26, 2010
  4. Chris Larsen

    Mime::Parser::Filer problemo

    Chris Larsen, Sep 10, 2003, in forum: Perl Misc
    Replies:
    0
    Views:
    103
    Chris Larsen
    Sep 10, 2003
  5. Gary Roach
    Replies:
    0
    Views:
    132
    Gary Roach
    Jan 2, 2014
Loading...

Share This Page