2014-07-17 5 views
1

입니다. 사용 사례는 다음과 같습니다. 나는 원격 컴퓨터에있는 파일을 나열하고 난 명령의 모습이SSH를 통해 원격 명령을 실행하지만 배경은

을 달성하기 위해 SSH를 사용하고이

/usr/bin/ssh -2 [email protected]_host ls -l remote_dir

이 잘 작동하고 나는 LS 출력을

그러나 오류 나가 내가 nohup 또는 백그라운드에서 실행할 때. 프로세스가 종료됩니다. 예를 들어, 아래 명령은 출력을주지 못합니다.

nohup /usr/bin/ssh -2 [email protected]_host ls -l remote_dir &

디버그 모드에서 실행하면이 오류가 나타납니다. 그것은

 
debug2: channel 0: read<=0 rfd 4 len -1^M 
debug2: channel 0: read failed^M 
debug2: channel 0: close_read^M 
debug2: channel 0: input open -> drain^M 
debug2: channel 0: ibuf empty^M 
debug2: channel 0: send eof^M 
debug2: channel 0: input drain -> closed^M 
debug2: tcpwinsz: 87380 for connection: 3^M 
debug2: tcpwinsz: 87380 for connection: 3^M 
debug2: channel 0: rcvd eof^M 
debug2: channel 0: output open -> drain^M 
debug2: channel 0: obuf empty^M 
debug2: channel 0: close_write^M 
debug2: channel 0: output drain -> closed^M 
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0^M 
debug2: channel 0: rcvd close^M 
debug3: channel 0: will not send data after close^M 
debug2: tcpwinsz: 87380 for connection: 3^M 
debug2: channel 0: almost dead^M 
debug2: channel 0: gc: notify user^M 
debug2: channel 0: gc: user detached^M 
debug2: channel 0: send close^M 

가 어떻게 백그라운드에서 목록을 원격 파일을 실행할 수 있습니다 폐쇄 등의 모든 연결을 고려하고 나는 표준 출력 및 표준 오류를 리디렉션 싶지 않아?

누군가 여기서 일어나는 일을 설명 할 수 있습니까?

답변

0

SSH 명령에 -t 인수가 전달되어야한다는 것을 알았습니다.

SSH에 대한 매뉴얼 페이지 내가 nohup을 함께 실행할 수 있었다 -t -t으로 SSH 명령을 실행에이

 
    -t  Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, 
      which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if 
      ssh has no local tty. 

을 말한다

 
nohup /usr/bin/ssh -2 -t -t [email protected]_host ls -l remote_dir & 

당신은 두 번 -t를 지정해야 tty 할당을 강제로 수행합니다.

관련 문제