安装模块:
1. perl Makefile.PL
2. make
3. make test
4. make install
|
文件: |
Expect-1.21.tar.gz |
大小: |
52KB |
下载: |
下载 | |
#!/usr/bin/perl
use Expect;
use strict;
my $timeout = 20;
my $cmd = "telnet";
my $exp = Expect->spawn($cmd,"192.168.0.1") or die "Can't spawn $cmd!";
$exp->expect($timeout,-re=>'[Ll]ogin:');
$exp->send("test\r\n");
$exp->expect($timeout,-re=>'[Pp]assword:');
$exp->debug(1);
$exp->send("test\r\n");
$exp->expect($timeout,-re=>'Last login');
$exp->send("ps -ef |grep java\r\n");
$exp->expect($timeout,-re=>'java');
print $exp->match_number();
$exp->soft_close();
阅读(804) | 评论(0) | 转发(0) |