我在机器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