perl的telnet模块调用cmd没有返回结果,请各位指导?
最近在学习perl,从网上下载学习脚本如下:
执行后,就没有反应了,不知道为什么,请
各位达人告知,谢谢!
#!/usr/bin/perl -w# file:remoteps.pluse strict;use Net::Telnet;use constant Timeout =>'5';use constant USER => 'test';use constant PASS => 'test';my $telnet=Net::Telnet->new( Timeout =>10, Prompt =>'/./', host =>'192.168.1.2' );$telnet->dump_log('log');$telnet->login(USER,PASS);my @lines=$telnet->cmd('ps -ef');print @lines;__END__
use strict;use warnings;use Net::Telnet;my $tnet=new Net::Telnet('Host'=>'127.0.0.1','Timeout'=>3,'Dump_Log'=>'test.log');$tnet->waitfor('Match'=>"/login:/");#适当的时候……$tnet->print("fibbery"); #输入适当的内容$tnet->waitfor('Match'=>"/password:/");#适当的时候……$tnet->print("mypassword"); #输入适当的内容$tnet->waitfor('/\>/');#等待命令行提示符my @lines=$tnet->cmd('String'=>"dir",'Prompt'=>'/fibbery\>/');#执行命令$tnet->print("exit");$tnet->close();print("@lines\n");