scp가 "해당 파일이 없습니다"라고 말하는 이유는 무엇입니까?

scp가 "해당 파일이 없습니다"라고 말하는 이유는 무엇입니까?

scp내 컴퓨터에서 다른 컴퓨터로 파일을 복사하는 bash 스크립트가 있습니다 . SSH 비밀번호를 입력한 후에도 스크립트는 다음 오류와 함께 계속 종료됩니다.

<filename>: No such file or directory

그러나 스크립트에서 파일을 확인했는데 모든 것이 정상입니다. 나는 set -o verbose 처음에 다음을 수행했고 이것이 스크립트의 끝에서 얻은 것입니다.

scp /Volumes/FX4\ HDD/Users/matthewdavies/Downloads/NCIS.S11E01.HDTV.x264-LOL.mp4 [email protected]:"/media/3TB/TV\ Shows/NCIS"
[email protected]'s password:
/Volumes/FX4\ HDD/Users/matthewdavies/Downloads/NCIS.S11E01.HDTV.x264-LOL.mp4: No such file or directory

그래서 명령을 출력으로 실행해 보았 scp더니 정상적으로 복사되었습니다. 무엇이 잘못되었나요? ? ?

답변1

나는 당신이 무엇을 하고 있는지 완전히 확신하지 못하지만, 당신의 예에서 명령을 시도하면 다음과 같은 결과를 얻습니다.

$ scp /home/saml/projects/Cooks.com\ -\ Recipe\ -\ Coconut\ Chicken.mht \
       root@remotey:"/root/some spaced out file.mht"
scp: ambiguous target

이는 대상 경로를 인용했고 여기에 공백을 이스케이프하는 백슬래시도 포함되어 있기 때문입니다. 그러나 현재 셸이 큰따옴표를 제거할 때 단일 백슬래시도 제거하여 대상 경로를 공백이 포함된 문자열로 남겨둡니다. 공백이 올바르게 이스케이프되도록 추가로 중첩하려면 다음 중 하나를 수행해야 합니다.

방법 #1 - 큰따옴표, 작은따옴표

$ scp /path/with\ spaces/file\ with\ spaces.txt \
       user@remotey:"'/home/user/some spaced out file.txt'"

방법 #2 - 작은따옴표, 큰따옴표

$ scp /path/with\ spaces/file\ with\ spaces.txt \
       user@remotey:'"/home/user/some spaced out file.txt"'

방법 #3 - 작은따옴표, 백슬래시

$ scp /path/with\ spaces/file\ with\ spaces.txt \
       user@remotey:'/home/user/some\ spaced\ out\ file.txt'

방법 #4 - 큰따옴표, 백슬래시

$ scp /path/with\ spaces/file\ with\ spaces.txt \
       user@remotey:"/home/user/some\ spaced\ out\ file.txt"

방법 #5 - 삼중 백슬래시

$ scp /path/with\ spaces/file\ with\ spaces.txt \
       user@remotey:/home/user/some\\\ spaced\\\ out\\\ file.txt

관련 정보