2012-03-29 8 views
1

私は、SSH経由でperlを使用してリモートでコマンドを実行するスクリプトを作成しています。 a)は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_configServerAliveIntervalは、あなたが探しているものであることを示唆している:あなたがのために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をチェックします。

関連する問題