2012-03-29 2 views
1

perl을 사용하여 SSH를 통해 원격으로 명령을 실행하는 스크립트를 작성하고 있습니다. 가) SSH 클라이언트가 SSH 클라이언트가 연결할 수) B를 연결할 수 없습니다하지만, 원격 명령 (말> 5 분) (A), theren 때문이다ssh 연결이 성공적으로 이루어진 후 데이터가 수신되지 않으면 ssh 클라이언트가 시간 초과 될 수 있습니까?

을 실행하는 데 시간이 더 많이 걸립니다 때 시간 초과가 발생할 수 있습니다 옵션은 ssh 클라이언트에서 사용할 수 있습니다. (b) 들어, 나는 아무것도 찾을 수 없습니다. 어떤 입력

답변

0

사용 Net::OpenSSH :

my $ssh = Net::OpenSSH->new($host, kill_ssh_on_timeout => 1, timeout => 5); 
my $output = $ssh->capture({tty => 1, timeout => 300}, $cmd); 

비록, 모듈 문서에 타임 아웃에 대해 the entry를 참조하십시오.

1

man ssh_config에 대한 덕분에 ServerAliveInterval 당신이 검색하는 것입니다 제안 : 당신은 무엇을를 loking하는 것은 타임 아웃 웨이크 업 기능이

ServerAliveInterval 
    Sets a timeout interval in seconds after which if no data has been received from the server, ssh(1) will send a message through 
    the encrypted channel to request a response from the server. The default is 0, indicating that these messages will not be sent 
    to the server, or 300 if the BatchMode option is set. This option applies to protocol version 2 only. ProtocolKeepAlives and 
    SetupTimeOut are Debian-specific compatibility aliases for this option. 
0

입니까? 신호를 보내는 데 익숙하다면 POSIX :: alarm()을 시도해보십시오. 또는 Perl 모듈 IPC :: Run을 점검하십시오.