Date: Mon, 31 Dec 2001 21:12:07 +1100
From: Cameron Simpson cs@zip.com.au
To: "douglas a. simmons" doug@mach6.org
Cc: secureshell@securityfocus.com
Subject: Re: need help escaping characters in scp2
User-Agent: Mutt/1.2.5i

On Sun, Dec 30, 2001 at 02:55:35AM -0800, douglas a. simmons jester@mach6.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.
|
| Example:
| I want to get /pathtofile/foo[1].txt from the remote host. I tried both of
| the
| following command which do not work.
|
| scp2 -p -d user@host:/pathtofile/foo[1].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 host. It's
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 end (being
protected at this end by the '').

I've just tested this here to make sure I'm not insane.

Clear?
--
Cameron Simpson, DoD#743 cs@zip.com.au http://www.zip.com.au/~cs/

When the only tool you have is Perl, the whole world begins to look like
your oyster. - Roy Johnson rjohnson@shell.com