- 论坛徽章:
- 0
|
小弟想实现一个telnet xp的脚本。手动登陆如下:
C:\Documents and Settings\Administrator>telnet 192.168.1.122
欢迎使用 Microsoft Telnet Client
Escape 字符是 'CTRL+]'
您将要把您的密码信息送到 Internet 区内的一台远程计算机上。这可能不安全。您还要送
吗(y/n):n
Welcome to Microsoft Telnet Service
login: test
password:****
*===============================================================
Welcome to Microsoft Telnet Server.
*===============================================================
C:\Documents and Settings\test>
C:\Documents and Settings\test>exit
我写的脚本:
#!/usr/bin/perl -w -c
use Net::Telnet ();
$timeout = 10;
$host = '192.168.1.122'; # 远程主机地址
$tn = new Net::Telnet (Timeout => $timeout,
); #端口默认
$tn->open($host);
$tn->waitfor('m,y/n,')|| die "error1";
$tn->waitfor('/login/')|| die "error2";
$tn->print("test");
$tn->waitfor('/pass/')|| die "error3";
$tn->print("test");
$tn->print("exit");
$tn->close;
执行的结果:
C:\Program Files\DzSoft\Perl Editor\Samples>perl bb.pl
pattern match timed-out at bb.pl line 8
C:\Program Files\DzSoft\Perl Editor\Samples>
总是提示第八行匹配有问题,是怎么回事?请大家帮个忙,谢谢!!! |
|