Tuesday, March 26, 2013

scp files with spaces in the filename

scp is a great tool. Built to run over ssh it maintains a good unix design. It does however cause a few problems with it's nonchalant handling of file names.

For example, transferring a file which has a space in the name causes problems because of the amount of escaping required to get the space to persist on the remote side of the connection.

Copying files from local to remote is easy enough, just quote or escape the file name using your shell.
scp Test\ File remote:
scp 'Test File' remote:
scp "Test File" remote:

Copying files from remote to local can be more tricky
scp remtote:Test\ File .
scp: Test: No such file or directory
scp: File: No such file or directory


scp stimulus:"Test File" .
scp: Test: No such file or directory
scp: File: No such file or directory


scp "stimulus:Test File" .
scp: Test: No such file or directory
scp: File: No such file or directory


The escaping is working on your local machine but the remote is still splitting the name at the space.

To solve that, we need an extra level of escape, one for the remote server. Remember that your shell will eat the \ so you need a double \\ to send it to the remote
scp remote:Test\\\ File .
Test File              100%    0     0.0KB/s   00:00

You can also combine the remote escape with local quoting
scp remote:"Test\ File" .
or
scp "remote:Test\ File" .

Best solution of all, avoid spaces in file names. If you can't avoid it, I find the easiest solution is to replace ' ' with '\\\ '.
 

23 comments:

  1. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. Slope is a game of fast reflexes. You control a ball with the arrow keys, guiding it down a treacherous slope filled with obstacles.

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. I hope there will be more of this type of publication.Tessa

    ReplyDelete
  4. The article you have shared here very awesome. I really like and appreciated your work. I read deeply your article, the points you have mentioned in this article are useful minecraft

    ReplyDelete
  5. I saw the some reference online but I don't understand perfectly, can any one help on this?

    most fun games 69

    ReplyDelete
  6. I was very pleased to find this web-site. I wanted to thanks for your time for this wonderful read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you blog post.

    Habotao.com
    Information
    Click Here
    Visit Web

    ReplyDelete
  7. The next time I read a blog, I hope that it doesnt disappoint me as much as this one. I mean, I know it was my choice to read, but I actually thought you have something interesting to say. All I hear is a bunch of whining about something that you could fix if you werent too busy looking for attention.

    Player.me
    Information
    Click Here
    Visit Web

    ReplyDelete
  8. I find this post so interesting. Keep us updated! Click here

    ReplyDelete
  9. beth dutton hat season 4 serves as a visual representation of her unwavering loyalty to her family and their ranching legacy. With its rich earthy tones and rugged texture, it embodies her deep connection to the land and the untamed nature of the American West.

    ReplyDelete
  10. "The cakespricing.com on this website are a testament to the skill and passion of the bakers."

    ReplyDelete
  11. To copy files from a local system to a remote system using Infinite Craft SCP when the filenames contain spaces, you need to properly escape the spaces.

    ReplyDelete
  12. "Our vacation was a huge success, thanks to mcinternationalsmeticulous planning."

    ReplyDelete
  13. "The cloud production on sprkvapors is impressive for a pod system. Perfect for a satisfying vape break."

    ReplyDelete
  14. "mclodges.com provides a home away from home experience."

    ReplyDelete
  15. fnaf has created a rare horror atmosphere, where the fear does not come from gruesome images, but from the extreme tension when you know that every passing moment could be the last.

    ReplyDelete
  16. The main Emoji Kitchen objective is to combine emojis in unique ways. The game allows players to experiment with a vast range of emoji pairs to discover all the possible combinations. Some combinations are cute, while others can be unexpected or even absurd, adding an element of surprise to the game.

    ReplyDelete
  17. While scp is a powerful and efficient tool for file transfers, it's essential to be mindful Papa's Pizzeria of filename handling to prevent confusion and errors.

    ReplyDelete
  18. Build Now GG provides a competitive and enjoyable gaming experience. The fast-paced action keeps me on my toes, and the building aspect adds depth to the gameplay. The game modes offer variety, and it's easy to jump in and start playing.

    ReplyDelete
  19. Combine different Sprunki Game sounds to create a harmonious or experimental track. You can mix percussion, vocals, effects, and melodies to achieve your desired style.

    ReplyDelete