就TELNET.pm的问题
perl编程,在服务器上Telnet到客户端,运行客户端程序.(客户端程序运行时,判断子程序是否存在,若不存在,则ftp从服务器上下载,完毕后运行子程序),在Aix,Trubo Linux,Hp-Unix上运行都很正常.但是在Solaries上客户端程序经常无法运行起来..求大侠指点..
以下是程序Telnet功能模块:
#!/usr/bin/perl
use FindBin qw($Bin);
use lib ("$Bin/../lib");
use Net::Telnet;
sub sub_opentelnet{
my ($ip) = @_;
my $ErrInfo;
my $t;
my $tmpresult = eval {$t = new Net::Telnet (Host => $ip,Timeout => 30,Prompt => '/.*[\%\$\#\>] $/')};
if(!$tmpresult){
return "LINK_ERROR";
}else{
return $t;
}
}
sub sub_logintelnet{
my ($t,$username,$passwd) = @_;
$tmpresult = eval{$t->login($username, $passwd)};
if(!$tmpresult){
return "LOGIN_FAIL";
}else{
return $t;
}
}
sub sub_closetelnet{
my ($t) = @_;
my $tmpresult = eval {$t->close};
return ;
}
sub sub_telnetsendcmd{
my ($t,$cmd)= @_;
my $ErrInfo;
my @line;
my $tmpresult = eval{@line = $t->cmd($cmd)};
if(!$tmpresult){
return "RUNCMD_FAIL";
}else{
if(defined(@line)){
#去掉提示符--如果不是在本机执行,不用去掉提示符。
#去掉换行符
chomp @line;
}
return @line;
}
}
1;
在服务端程序中调用
....
...
#发送命令,执行客户端脚步程序..
($cmdresult) = &sub_telnetsendcmd($telnet,$cmd);
&writelog($LogFile,"$clientname $cmdresult ");
if($cmdresult eq "RUNCMD_FAIL"){
$ErrInfo = "$clientname 运行命令$cmd出错";
&writelog($LogFile,$ErrInfo);
&writeretryfile($TelnetTemp,$clientname,$clientip,$clientuser,$clientpasswd);
&sub_closetelnet($telnet);
exit;
}elsif($cmdresult eq ""){
$ErrInfo = "$clientname 运行命令$cmd出错$cmdresult";
&writelog($LogFile,$ErrInfo);
&writeretryfile($TelnetTemp,$clientname,$clientip,$clientuser,$clientpasswd);
&sub_closetelnet($telnet);
exit;
}
通过日值记录,($cmdresult) = &sub_telnetsendcmd($telnet,$cmd);有数据返回,但是客户端程序无法执行.
请大侠指点.谢谢..急6