Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A script to ease scp for files with odd names' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to ease scp for files with odd names
Authored by: TGV on Sep 13, '07 12:30:03PM
scp-to-coppit.org File with weird char's.txt
No, you can't. Not in the shell anyway, since it will look for the closing quote and not include the quotes in the text. In this case, the shell will simply give you the secondary prompt and wait until you've typed another quote or escaped your way out (^G, ^C). And if you've typed the second quote, the error is most likely going to be "file not found".

According to me, by I'm a command line user since the early 80's, it's much easier and safer to use the built in completion, e.g. using the tab key.

Suppose my directory contains these three files

  • File with weird char's.txt
  • File with another weird@character.txt
  • anotherfile.txt

Then typing

$ scp F<TAB>

will show

$ scp File\ with\

because that's the unique starting part. The choice has now boiled down to the first two files. At that point, typing w and another TAB will fill in the entiry name, resulting in

$ scp File\ with\ weird\ char\'s.txt

an you're ready to type the destination. Or you could make the script with the destination in it, but without the weird and potentially dangerous argument mangling.

And it is dangerous, since the arguments are joined with single spaces and thus (under bizarre circumstances admittedly (*)) you could be overwriting an unwanted file at the destination.

(*) Think of file names with more than one consecutive space and differing with another file in only the spaces, not to mention files with backslashes in their name...

[ Reply to This | # ]

A script to ease scp for files with odd names
Authored by: rjbailey on Sep 14, '07 10:17:36AM

Then how to do batch scp transfers, e.g. "scp *.txt" and the like? Tab-completion won't work in those cases.



[ Reply to This | # ]
A script to ease scp for files with odd names
Authored by: TGV on Sep 14, '07 11:00:49PM

That's true, but the original script doesn't do that either: if you type a * in calling, it will be expanded to contain all files in the directory.

If you want to do that kind of thing and have trouble using the command line, I recommend something like CyberDuck or Yummy FTP, which can (apparently) do FTP over SSH (or actually, SFTP, which is part of it).



[ Reply to This | # ]