using Net::SSH2 shell 的二个方法,供大家参考。
方法一:
复制代码 代码如下:
$chan2 = $ssh2->channel();
$chan2->blocking(0);
print $chan2 "tail -5 /var/log/authlogn";
print "**$_" while <$chan2>;
方法二:
复制代码 代码如下:
#shell use
my $chan2 = $ssh2->channel();
$chan2->shell();
print $chan2 "uname -an";
print "LINE : $_" while <$chan2>;
print $chan2 "whon";
print "LINE : $_" while <$chan2>;
$chan2->close;