Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: scp protocol error on multiple file copy?



On Fri, 1 Nov 2019 08:30:24 -0000 (UTC), mlelstv%serpens.de@localhost (Michael
van Elst) wrote:

> jdbaker%consolidated.net@localhost ("John D. Baker") writes:
> 
> >On the remote, it invokes 'scp' with an undocumented "-f" (lowercase
> >"f") switch:
> 
> >  debug1: Sending command: scp -v -p -f /path/to/@(sets/@([bem*|text.tgz)|kernel/netbsd-CUSTOM.gz)
> 
> >passing it the path/fileglob given on the local host.
> 
> 
> Actually that is passed to the shell first, if the shell doesn't interpret
> the globbing, it passes it then unchanged to the command.
> 
> The '-f' and the '-t' are the hidden flags that tell the scp command to
> serve the operation on the remote machine, depending on direction (from,to):
> 
> % scp fud:'@(raid0|raid1).label' .
> protocol error: filename does not match request
> 
> With -v you see that the remote machine (with ksh) correctly globs
> that pattern and tries to send the files:
> 
> Sink: C0644 894 raid0.label
> Sending file modes: C0644 894 raid0.label
> protocol error: filename does not match request
> Sending file modes: C0644 890 raid1.label

This is interesting because my shell is 'ksh' yet for some reason it's
not interpreting the "@(foo|bar)" filename patterns and I get "No such
file or directory."  It does, however, interpret "[abcd]", "?" and "*".

> But the local scp client tries to parse the answers and since it doesn't
> understand the ksh pattern, it rejects the files sent. The -T flag skips
> that pattern check.
> 
> % scp -T fud:'@(raid0|raid1).label' .
> raid0.label                                   100%  894   266.4KB/s   0.9KB/s  
> raid1.label                                   100%  890   305.3KB/s   0.9KB/s  

Adding "-T" to my original multiple-file command:

  scp -p -T buildhost:"/path/to/sets/[bem]* /path/to/sets/text.tgz /path/to kernel/netbsd-CUSTOM.gz" .

worked.

> Unlike the globbing on the remote side, the local check doesn't use the
> shell to interpret the pattern. Instead scp itself splits braced sequences
> like '{a,b,...}' and calls fnmatch() to handle the parts.

Interesting as I couldn't get that to work either.  Trying to use any
advanced filename pattern or brace expansion always results in "No such
file or directory."

> scp is a hack.

That apparently has stopped working for me.

-- 
|/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
|\ / jdbaker[snail]consolidated[flyspeck]net  OpenBSD            FreeBSD
| X  No HTML/proprietary data in email.   BSD just sits there and works!
|/ \ GPGkeyID:  D703 4A7E 479F 63F8 D3F4  BD99 9572 8F23 E4AD 1645


Home | Main Index | Thread Index | Old Index