Date: Mon, 31 Dec 2001 21:12:07 +1100
From: Cameron Simpson firstname.lastname@example.org
To: "douglas a. simmons" email@example.com
Subject: Re: need help escaping characters in scp2
On Sun, Dec 30, 2001 at 02:55:35AM -0800, douglas a. simmons firstname.lastname@example.org wrote:
| How do I escape the characters '[' and '(' when using scp2
to get a file
| that contains those characters on a remote server?
| I tried escaping them with '\' like '\[' and '\(' but it did not work.
| I want to get /pathtofile/foo.txt from the remote host. I tried both of
| following command which do not work.
| scp2 -p -d user@host:/pathtofile/foo.txt /path/
| scp2 -p -d user@host:/pathtofile/foo\[1\].txt /path/
You need to do it twice.
The problem is that the string after
user@host: is being passed to the
shell to for file expansion - at the far end. This is maybe a misfeature,
but it lets people say this:
scp 'user@host:foo*' .
to copy all the files starting with "foo" from the remote
existed that way in rcp for many years and is presumably the same here
because scp is meant to be able to function as a drop in rsh replacement.
So you must arrange for the characters to be quoted _at_the_far_end_:
scp -p -d user@host:'/pathtofile/foo\[1\].txt' /path/
In this the '' quote for this end and the \ quote for the far
protected at this end by the '').
I've just tested this here to make sure I'm not insane.
When the only tool you have is Perl, the whole world begins to
your oyster. - Roy Johnson email@example.com