Monday, May 28, 2007

scping files with spaces in them

nothing l33t...

but if you have to scp files with spaces in them and you dont do it right you can get a stupid

scp: ambiguous target

error, which can be quite unfun.

example:

scp "Other Linux 2.6.x kernel-cl1.vmdk" root@192.168.0.1:"Other Linux 2.6.x kernel-cl1.vmdk"
root@192.168.0.1's password:
scp: ambiguous target

The issue is that even though its in quotes scp is looking at it as "Other" as a file and "Linux" as a file..

here's the fix

scp Other\ Linux\ 2.6.x\ kernel-cl1.vmdk root@192.168.0.1:"Other\ Linux\ 2.6.x\ kernel-cl1.vmdk"
root@192.168.0.1's password:
Other Linux 2.6.x kernel-cl1.vmdk 100% 2043MB 10.9MB/s 03:07

you can also leave out the escape characters in the source files and just put the source file in quotes, but you'll need them on the destination file.

scp "Other Linux 2.6.x kernel-cl1.vmdk" root@192.168.0.1:"Other\ Linux\ 2.6.x\ kernel-cl1.vmdk"
root@192.168.0.1's password:
Other Linux 2.6.x kernel-cl1.vmdk 100% 2043MB 10.9MB/s 03:07

hope that helps someone :-)

8 comments:

  1. Helped me too! Thanks!

    ReplyDelete
  2. Very good one. Many thanks!

    ReplyDelete
  3. Thanks for this. I was so convinced that my ssh config was the problem, but it was just the spaces.

    ReplyDelete
  4. Thanks, fixed my problem

    ReplyDelete
  5. Thanks - that one was driving me crazy.

    ReplyDelete
  6. Awesome. Thank you. I was going nuts!

    ReplyDelete