Net::SCP::Expect中的auto_yes不起作用?

Net::SCP::Expect中的auto_yes不起作用?

use Net::SSH:erl;
use Net::SCP::Expect;
use strict;
my @host=`cat /opt/host.list`;
my $user='root';
print "assword: ";
my $pass = <STDIN>;
chomp($pass);


while(@host){
my $host=shift(@host);
chomp($host);
my $scpe = Net::SCP::Expect->new(auto_yes=>1,timeout=>30);
$scpe->login($user, $pass);
$scpe->scp('/root/m.rpm',"$host:/root";
}

在CPAN里看到的
OPTIONS auto_yes - Set this to 1 if you want to automatically pass a 'yes' string to any yes or no questions that you may encounter before actually being asked for a password, e.g. "Are you sure you want to continue connecting (yes/no)?" for first time connections, etc



问题是上了这个option,我执行perl脚本调用SCP时候还是要让我手工输入yes

The authenticity of host 'xxx.xxx.xxx.xxx' can't be established.
Key fingerprint is b4:3a:22:a1:ba:3b:81:03:04:92:41:fd:df:85:b4:4d.
Are you sure you want to continue connecting (yes/no)? [yes] yes




是什么问题,请做过的大大说一下,或者根本就是这个模块的BUG?
自己 hack 一下,应该不难。
新手,刚学二天。。。。。不会HACK
http://search.cpan.org/src/DJBERG/Net-SCP-Expect-0.12/Expect.pm
看他的source code...
应该有一个
$scpe->debug(1)的method....
再看Expect的说明..
可以用
  $object->debug($debug_level); #--可以设定成1..
  $object->exp_internal(0 | 1); #--设定成1
这两个method会把所有的过程都打印出来..
就可以知道那边有问题了.....

谢谢apile的回复,看了一下您给的源代码,然后打开了
$scpe->debug(1)
执行perl 报错了
Can't locate object method "debug" via package "Net::SCP::Expect" at interactive.sh line 21, <STDIN> line 1.

我看代码里,  
if($auto_yes){
      while($scp->expect($timeout_auto,-re=>'[Yy]es\/[Nn]o')){
         $scp->send("yes\n";
      }
   }

有$timeout_auto,所以我也设置了一下,但是问题依旧,
发现了一个问题

在交互过程中,SCP 提示的信息是
Are you sure you want to continue connecting (yes/no)? [yes]

而在源代码中:while($scp->expect($timeout_auto,-re=>'[Yy]es\/[Nn]o')){

交互过程中多了[yes],是不是不匹配造成的问题呢?
看出来问题了...
你得直接修改
Net-SCP-Expect-0.12/Expect.pm 应该在@INC目录中...

source里面..在
sub scp{}
里面的
my $scp = Expect->new();
後面加上
$scp->debug(1);

$scp->exp_internal(1);

後面的
$scp->log_stdout(0);
要改成
$scp->log_stdout(1);

然後就可以看到所有的过程....

debug完记得要改回来喔......

或设定
verbose引数....

最好还是先看看是哪里有问题...我猜是没有匹配到yes/no...

你说的while应该不是 bug....他只是尝试去匹配多个yes/no...

DEBUG是打开了 不过看不出什么东西。。。。
DEBUG中还是让我打yes 确认主机,晕啊。

我这里200多台主机 yes要打死了


Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/site_perl/5.8.5/Expect.pm line 1431, <STDIN> line 1.
Closing .
at /usr/lib/perl5/site_perl/5.8.5/Expect.pm line 1431
        Expect::hard_close('Expect=GLOB(0x52a660)') called at /usr/lib/perl5/site_perl/5.8.5/Expect.pm line 1621
        Expect:ESTROY('Expect=GLOB(0x52a660)') called at /usr/lib/perl5/site_perl/5.8.5/Net/SCP/Expect.pm line 179
        eval {...} called at /usr/lib/perl5/site_perl/5.8.5/Net/SCP/Expect.pm line 179
        Net::SCP::Expect::scp('Net::SCP::Expect=HASH(0x506160)', '/root/m.rpm', 'IP:/root') called at interactive.sh line 23
Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/site_perl/5.8.5/Expect.pm line 1434, <STDIN> line 1.
closed.
The authenticity of host 'IP' can't be established.
Key fingerprint is ae:bd:c3:3b:79:be:43:82:a4:bc:d6:26:33:7a:ad:2c.
Are you sure you want to continue connecting (yes/no)? [yes] yes
改成打开exp_internal...
可以看到更多data
......问题解决了,打开exp_internal发现,auto_yes是有作用的,

模块是自动帮我yes了,

只不过我写的perl后面又调用了 Net::Ssh:erl
连了一次ssh,

所以那个确认信息是ssh产生的。。。

谢谢apile ,让您费心了