expect 求助

expect 求助

我写了一段Perl代码, 利用Expect自动登录交换机,代码如下:
use Expect;
use strict;
use warnings;

sub readdata{
open(FILEHANDLE,"change.txt"||die"can not open filename!";
my(@array)=<FILEHANDLE>;
chomp@array;
close(FILEHANDLE);
return(@array);
}

my @list=&readdata;
for(my $i=0;$i<=$#list;$i++){
        my @route=split /,/,$list[$i];
        my $timeout = 1;
        my $cmd1 = "telnet";



        my @params = "$route[0]";
        my $exp = new Expect;
        $exp->raw_pty(1);
        $exp->log_file("debug.txt", "w";
        $exp->spawn($cmd1,@params) or die "Can't spawn $cmd1!";
        $exp->expect($timeout,-re=>"Username:";
        $exp->send("$route[1]\r\n";
        $exp->expect($timeout,-re=>"assword:";
        $exp->send("$route[2]\r\n";
        $exp->expect($timeout,-re=>">";               
        $exp->send("su\r\n";
        $exp->expect($timeout,-re=>"assword:";
        $exp->send("$route[3]\r\n";
        $exp->expect($timeout,-re=>">");               
        $exp->send("sy\r\n");
        $exp->expect($timeout,-re=>"]");
        $exp->send("$route[4]\r\n");
        $exp->expect($timeout,-re=>"]");
        $exp->send("q\r\n");
        $exp->expect($timeout,-re=>">");
        $exp->send("save\r\n");
        $exp->expect($timeout,-re=>">");               
        $exp->send("q\r\n");

        $exp->soft_close();
        $exp->log_file(undef);
}


但不知道为什么总是不能执行, 运行也不报错, 没有任何输出. 我在Cygwin下运行的,哪位大侠帮忙看看.

详细的debug输出。
望大侠告知如何debug, 我是新手。
You can also set

  $Expect:ebug = 1;  # or 2, 3 for more verbose output

or

  $exp->debug(1);