Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Why can't I copy with scp when I'm using * characters in the path?

scp SERVERNAME:/DIR/* .

What configs do SCP need to allow * in the path?

UPDATE: the problem is not on server side, pscp is trying to use SCPv1, and that's why the error message:

enter image description here

share|improve this question
    
very carefully. –  Shadur Dec 22 '11 at 14:26
    
Since it looks like you are using putty, this may be relevant. –  jw013 Dec 22 '11 at 16:54
3  
If you are using scp on Windows, I don't think this is the appropriate forum. –  Chris Down Dec 23 '11 at 13:32

2 Answers 2

You need to pass a literal escape to scp to avoid the remote machine treating * as a glob (notice that it is doubly quoted):

scp 'SERVERNAME:/DIR/\*' .
share|improve this answer
3  
You either need quotes, or a backslash before the star, not both. And scp is not the one expanding it, the shell is. –  Patrick Dec 23 '11 at 4:39
    
@Patrick That's not correct, scp expands the glob, even if your shell doesn't (you can try it for yourself). There are two stages: stopping your shell from expanding the glob (which is not necessary because it should have nothing to expand the glob to, and thus will remain intact), and telling scp that this character is not a glob. If it was your shell expanding the glob you would not have to escape it at all. –  Chris Down Dec 23 '11 at 13:29
    
Er, rather, the shell on the other end expands the glob, not scp. –  Chris Down Dec 6 '13 at 17:44
    
Have you tried it? I just did, works exactly as I described (quoting and escaping causes failure). User1274964 even confirms the behavior in his answer. touch /tmp/abcd.1234; scp 'localhost:/tmp/abcd.\*' ./: scp: /tmp/abcd.*: No such file or directory –  Patrick Dec 7 '13 at 1:00
2  
@Patrick The question is about using a literal asterisk, ie, avoiding globbing altogether, not about how to glob on the remote. –  Chris Down Dec 8 '13 at 20:57

I found Patrick's advice to be correct, although Chris's answer got me on the right track. Use quotes and then you don't need the backslash before the asterisk.

scp 'SERVERNAME:/tmp/file_num\*' .

scp: /tmp/file_num*.csv: No such file or directory

scp 'SERVERNAME:/tmp/file_num*' .

judgments_for_job_171642.csv 100% 32KB 32.0KB/s 00:00
judgments_for_job_172394.csv 100% 548KB 182.6KB/s 00:03

share|improve this answer
2  
Right, because this means that you want to glob on the remote. The question is about how to stop globbing on the remote (to get a literal *), not about how to glob on the remote only. –  Chris Down Dec 8 '13 at 20:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.