直接在host上telnet XXXX是可以的,在pc1上直接運行tqtest也是可以的,但是從auto中運行腳本就會報錯:
Connection closed by foreign host.
並且在/var/log/messages中顯示:
Aug 14 22:55:42 VTB93-PC2 xinetd[18654]: START: telnet pid=18688 from=13.0.0.10Aug 14 22:55:42 VTB93-PC2 telnetd[18688]: ttloop: peer died: EOF
Aug 14 22:55:42 VTB93-PC2 xinetd[18654]: EXIT: telnet status=1 pid=18688 duration=0(sec)
改成使用
use Net::Telnet;
my $telnet = new Net::Telnet(
'timeout' => 10,
'host' => "$DESTINATION",
'family' => "ipv6",
) or die "telnet failed:".$telnet->errmsg;
$telnet->waitfor('Match'=>"/login:/") or die "there are not login:".$telnet->errmsg;
$telnet->print("root");
$telnet->waitfor('Match'=>"/[Pp]assword:/");
my $lastline = $telnet->lastline;
$telnet->print("exit");
$telnet->close();
if($lastline =~ m/root/is){
return $TQTEST_PASS;
}