RE: how to copy filename with spaces using scp

From: Spiewak, Jakub (jakub.spiewak_at_citigroup.com)
Date: 12/16/03

  • Next message: David Cress: "SSH v3.7.1p2 client not failing back to SSH v1"
    Date: Tue, 16 Dec 2003 07:33:34 -0000
    To: "John Davidorff Pell" <johnpell@mac.com>, "Jerry Geis" <geisj@pagestation.com>
    
    

    If I may have a question

    If You are trying to interact with Server placed on Windows platform, You face problems with not only files with space but also with areas with space.

    Example:
            if I would like to transfer c:\Program Files\test\test file.tmp
            to my Unix box, what shall I do?
            

    Regards,
    Jakub.

    -----Original Message-----
    From: John Davidorff Pell [mailto:johnpell@mac.com]
    Sent: Monday, December 15, 2003 2:05 AM
    To: Jerry Geis
    Cc: Secure Shell
    Subject: Re: how to copy filename with spaces using scp

    Jerry Geis <geisj@pagestation.com> wrote:
    > How do I escape the spaces in an automated way?
    > I am not typing this command it is running from an
    > automated file. something like
    >
    > ssh remote find /home/jerry > file_list
    > the use every file name in the file_list and scp
    > that file from remote to local.
    >
    > THanks,
    >
    > jerry
    >
    >
    > John Davidorff Pell wrote:
    >
    > You should try:
    > $ scp remote:"/file\ with\ spaces.txt" /tmp
    > instead of
    >> scp "remote:/file with spaces.txt" /tmp

    Ok, try:
    $ scp remote:"\"file with spaces.txt\"" /tmp

    This may not work because what local scp thinks the file name is:
    \"file with spaces.txt\" includes the quotes, which it shouldn't. You
    could use "--unsafe" to get around that, but here is a better way:
    $ scp remote:"\"file with spaces.txt\"" "/tmp/file with spaces.txt"

    That shouldn't be too hard to do inside the script. :-)

    It seems, from your example, that you are trying to copy *many* files.
    This is NOT the best way to go about if for a number of reasons:
    A) It is slow.
    B) It has tremendous overhead
    C) It floods the logs
    D) It is slow.
    E) It takes a very long time.
    F) Are you seeing a pattern?

    Here is a better way to copy large amounts of files:
    $ cd /tmp
    $ ssh remote tar c /home/jerry | tar x

    Basically, what this will do is archive your entire home folder, send
    it, then unarchive it. Here is a version with compression:
    $ cd /tmp
    $ ssh remote "tar c /home/jerry | gzip" | gunzip | tar x

    For *best* compression (over a slow link), change gzip to gzip -9

    You will end up with a folder named home in /tmp that contains a folder
    named jerry that has your entire home folder contents in it... :-D

    If you do not want the extra folders (/tmp/home/jerry) then you can use
    the -C flag for tar, but i'll leave that to you. (hint: "man tar")

    I've CC'd the list again, in case anyone else has any tips. :-)

    Good luck!
    JP

    --
    ". . . Through the cold and darkness
    we will look back on this day
    and fall into oblivion.
    Through a brilliance beyond twilight
    we will rise again,
    ready to face the dangers that befall on us . . ."
    

  • Next message: David Cress: "SSH v3.7.1p2 client not failing back to SSH v1"

    Relevant Pages

    • Re: how to copy filename with spaces using scp
      ... Jerry Geis wrote: ... $ ssh remote tar c /home/jerry | tar x ... Basically, what this will do is archive your entire home folder, send ... You will end up with a folder named home in /tmp that contains a folder ...
      (SSH)
    • Re: Various File Save error messages with Word 2004 and Tiger (10.4.2) Server
      ... > Did the ".TemporaryItems" thing, and it seemed to work for a while (a few ... >> the Homes folder on the server. ... >>> Word is having various problems saving to remote home folder (henceforth RH, ...
      (microsoft.public.mac.office.word)
    • Re: Redirected Folders wont allow offline folders (article 288991
      ... The 9 sites are single server sites ... This folder subfolders and files ... and the Home folder security settings, share permissions, and GPO's for ... permissions to Allow: ...
      (microsoft.public.windows.server.general)
    • Re: Issue with home folders
      ... But I dont seem to understand how could a user become mapped to a root share ... Yes I am thinking that folder redirection would probably be best but I ... I seem to have a wierd issue with home folder for users. ...
      (microsoft.public.windows.server.active_directory)
    • Re: OSX: whats the damn deal with "priveleges"
      ... It is your Home folder ... There is another Library folder you will need to know about, ... use automatic login, they would probably not even list available users ...
      (comp.sys.mac.apps)