【发布时间】:2014-05-27 18:11:53
【问题描述】:
我尝试在失败时打印“错误 IP USER PASS 失败!”。
当我使用我的脚本时
use Net::Telnet ();
my $t = new Net::Telnet Timeout => 30,
Prompt => '/[\$#%:><][\s\b]+$/';
$t->open($ARGV[0]);
my $user = $ARGV[1];
my $pass = $ARGV[2];
print "Logging In...\n";
print "Sending Username....\n";
$t->print($user);
$t->waitfor('/[:>%\$#]/');
print "Sending Password....\n";
$t->print($pass);
$t->waitfor('/[:>%\$#]/');
if ($t->errmsg){
print "errmsg: " . $t->errmsg . "\n";
} else {
print"success\n";
}
问题:
我知道 IP 和用户名:admin 和 admin 正在工作。
root@localhost:~/tel# perl t2.pl *.*.*.* admin admin
Logging In...
Sending Username....
Sending Password....
success
现在使用非工作用户并通过我得到相同的“成功”
root@localhost:~/tel# perl t2.pl 36.85.134.191 admin admi1
Logging In...
Sending Username....
Sending Password....
success
我在 if 语句中做错了什么,有些东西不能正常工作。
【问题讨论】:
标签: perl error-handling telnet