Tuesday, December 9, 2008

SCP fail

I was trying to copy a bunch of pdfs from my desktop to a server using scp. This command failed:

/usr/bin/scp user@example.com:~/foo/bar/*.pdf Training/


It returned a error saying "/usr/bin/scp: No match.". This is because the regex wildcard is expanded on the local machine (in this case the server) where the files are not present and therefore not found.

Whereas this one worked.
/usr/bin/scp user@example.com:~/foo/bar/\*.pdf Training/

Notice that the wildcard is now escaped so that it is ignored on the server but will be expanded when scp gets to the remote machine.