using Net::SSH2 shell 的二个方法
程序员文章站
2022-04-29 20:14:13
方法一:复制代码 代码如下:$chan2 = $ssh2->channel();$chan2->blocking(0);print $chan2 "tail -...
方法一:
复制代码 代码如下:
$chan2 = $ssh2->channel();
$chan2->blocking(0);
print $chan2 "tail -5 /var/log/authlog\n";
print "**$_" while <$chan2>;
方法二:
复制代码 代码如下:
#shell use
my $chan2 = $ssh2->channel();
$chan2->shell();
print $chan2 "uname -a\n";
print "line : $_" while <$chan2>;
print $chan2 "who\n";
print "line : $_" while <$chan2>;
$chan2->close;