2
我有一個Perl腳本,它使用openssh訪問遠程計算機並在該遠程計算機上執行Perl腳本。將stdin輸入傳遞給perl腳本以進行遠程執行
現在的問題是,需要在遠程機器上執行的腳本是一個交互式腳本,並期望通過STDIN執行期間的一些輸入。
有人能幫我實施這個情景嗎?
我正在放置我已經執行到現在的代碼片段。
my $ssh = Net::OpenSSH->new("$host", timeout => 60) or die "unable to connect to remote host: ". $ssh->error;
$ssh->system("chmod 755 abc.pl");
my $output=$ssh->capture("./abc.pl") or die "remote command failed: " . $ssh->error;
請參閱:http://search.cpan.org/~bnegrao/Net-SSH-Expect-1.09/lib/Net/SSH/Expect.pod – ceving
'capture'爲此提供了選項'stdin_data'。如果交互很複雜,您可能會喜歡使用Expect。閱讀模塊文檔! – salva