using Net::SSH2 shell 的二个方法
发布时间:2016-12-28 来源:查字典编辑
摘要:方法一:复制代码代码如下:$chan2=$ssh2->channel();$chan2->blocking(0);print$chan2"t...
方法一:
复制代码 代码如下:
$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;