는 test.sh
시도가이 오류가 발생합니다 badcommand
를 호출 할 때, 볼 수 있듯이이
MPBAB:work anj$ cat test.sh
echo "Hello there"
echo "This is a test script"
badcommand
MPBAB:work anj$ ./test.sh 2> err.log
Hello there
This is a test script
MPBAB:work anj$ cat err.log
./test.sh: line 4: badcommand: command not found
을 어떻게 작동하는지입니다. 그러나 두 echo
문은 정상적으로 작동하며 STDOUT
에 표시되고 STDERR
은 err.log
에 기록됩니다.
은 이제
MPBAB:work anj$ ./test.sh . 2>err.log
Hello there
This is a test script
MPBAB:work anj$ cat err.log
./test.sh: line 4: badcommand: command not found
이 같은 방식으로 작동 점프는 - 시도 방법을 구현. 귀하의 경우에 나는 당신이 발행하고있는 scp
명령이 정확하지 않다고 생각해야합니다. scp
은 source
및 destination
이 필요합니다. (필자는 원격 서버에 scp
있는 test.txt하려는) 이런 식으로 뭔가
MPBAB:work anj$ scp ./test.txt [email protected]:/home/data 2>scperr.txt
[email protected]'s password: #<this is because I dont have the public key installed>
test.txt 100% 291 0.3KB/s 00:00
MPBAB:work an$ cat scperr.txt
MPBAB:work anj$
그래서 당신은 파일이 복사가 STDOUT
에 test.txt 100% 291 0.3KB/s 00:00
을 보여주고 있었다 때문에 오류가 scperr.txt
비어 있지 않은지, 참조하십시오.
흠, 네가 한 일이야. stdout (진행 정보)이 터미널로 출력되고 stderr이 errfile.txt로 전송됩니다. BTW, 확장에서 첫 번째 인수에서 별을 보호하는 것이 좋습니다 : '\ *. txt'. 그렇지 않으면 컴퓨터에있는 파일 이름으로 확장되어 원하는대로되지 않습니다. – fork0
나는 이것을 시도했다 : scp user @ XXX :/$ PATH/test *. 2>/tmp/test, openssh 클라이언트와 그것의 작품, 나는 sdout 모든 파일을 복사 한 "/ tmp/test"파일에 허가가 거부되었습니다. Sh -> dash 및 ssh 클라이언트 : OpenSSH_5.3p1 Debian-3ubuntu7, OpenSSL 0.9.8k 2009 년 3 월 25 일 – Duffydake