Linux – SCP command with spaces and a comma

linuxscp

been having problems all day with this single scp command. Been searching and asking people etc etc.

$ scp -P portNumber /ReferenceFiles/CompanyA,The/Some\ DirectoryWithA\ Space/Game user@server:/ReferenceFiles/CompanyA/Game

I tried to do a file within the directory, but get file does not exists, and if I try to do the scp command on the directory I get "not a regular file".

I have tried using double back slashes for the spaces, using single and double quotes. I'm really new to this and have been thrown in expecting to know this stuff when I was told I would be doing mostly PHP and Flash…

Any help or suggestions welcome.

Thanks

Best Answer

One of the easiest ways to get around character escaping on the command-line (if that's the cause of the problem) is to use tab-completion to let it fill in the "awkward" characters; depending on how full your /ReferenceFiles directory is, you might be able to do something like

  scp -P portNumber /Ref<tab>CompanyA<tab>Some<tab>Game/file user@server:...

Alternately, you can use a ? instead of a character, provided there aren't going to be too many conflicting file/directory names:

 scp -P portNumber /ReferenceFiles/CompanyA,The/Some?DirectoryWithA?Space/Game/file ...

For directories, you need to use the -r option to scp (its omission is why you got the "not a regular file" error).

Lastly, could it be that the destination on the server doesn't exist as typed, and that's the source of the error (and not the source file)?

Related Topic