perl的telnet模块调用cmd没有返回结果,请各位指导?该如何解决

perl的telnet模块调用cmd没有返回结果,请各位指导?
最近在学习perl,从网上下载学习脚本如下:

执行后,就没有反应了,不知道为什么,请
各位达人告知,谢谢!

Perl code
#
!/usr/bin/perl -w
# file:remoteps.pl
use 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__


执行后,发现@lines没有值,但是login却是成功的,后来看看日志,是这样的:
< 0x00000: 4c 61 73 74 20 6c 6f 67 69 6e 3a 20 54 68 75 20 Last login: Thu 
< 0x00010: 41 70 72 20 32 32 20 32 31 3a 30 32 3a 33 34 20 Apr 22 21:02:34 
< 0x00020: 43 53 54 20 32 30 31 30 20 66 72 6f 6d 20 31 39 CST 2010 from 19
< 0x00030: 32 2e 31 36 38 2e 31 2e 31 30 30 20 6f 6e 20 70 2.168.1.100 on p
< 0x00040: 74 73 2f 30 0d 0a ts/0..

> 0x00000: 70 73 20 2d 65 66 0d 0a ps -ef..


------解决方案--------------------
Perl code

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");