在php中使用此脚本时:

echo "<br>"; 
echo "<pre>"; 
echo $ssh->exec('top'); 
echo "</pre>"; 
我收到此错误:
TERM未设置环境变量。

请您参考如下方法:

做$ssh->enablePTY()。看到这个:

http://phpseclib.sourceforge.net/ssh/pty.html#top

请注意,您必须使用File_ANSI(),以免输出没有任何意义。例如。

$ssh->enablePTY(); 
$ssh->exec('top'); 
$ssh->setTimeout(5); 
$ansi->appendString($ssh->read()); 
echo $ansi->getScreen(); 


评论关闭
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!