我在機器A上運行bash shell通過ssh運行在機器B上的perl shell,通過ssh向機器C請求命令結果。我無法獲得在機器A TTY所示結果...Bash/Perl鏈接SSH命令(A到B到C)
這裏是幾千的線路碼的總結:
1)上機 「A」 的bash 「A」:NOK
...
ssh -p port [email protected] "scriptB.pl"
...
2)perl scriptB.pl「在機器」B「上:OK
...
# my $user = qx|$ssh_cmd| if ($ssh_connection_ok);
my $user = qx#$ssh_cmd# if ($ssh_connection_ok);
...
3)上機 「C」 bash命令$ ssh_cmd:OK
cat /my_dir/my_file | grep this_user | head -n1 | cut -d: -f1 | tr
運行作爲獨立的,步驟2和步驟3中顯示的是預期的結果,但是從機械的運行scriptB.pl不會返回預期的數據。我目前不使用Net :: SSH2,而是使用qx。可能是客戶端ssh設置中的問題。
Thx in adv。
是,$?在機器B上運行scriptB時返回0,但在機器A上運行時返回65280.我應該如何解釋這個..?我也在機器B上本地運行scriptB,並從那裏獲得期望值。以及在machineC上運行cmd。我也試過在perl shebang之後加入$ | = 1,沒有差異。 – hornetbzz