- 論壇徽章:
- 0
|
本帖最后由 yanzy 于 2010-08-12 14:49 編輯
有時候匹配得過去,有時候匹配不過去得,請大俠幫忙
問題在這一塊Are you sure you want to continue connecting (yes/no)?
- #!/usr/bin/perl
- use Expect;
- $ENV{TERM} = "vt100";
- my @server_ip=('10.8.4.136');
- my $ip=@_;
- # my $exp = Expect->new;
- foreach $ip(@server_ip){
- my $timeout = 2;
- my $pass="Paic1234";
-
- $exp = Expect->spawn("ssh -l yanzy $ip");
- $exp->log_file("output.log");
- $exp->exp_internal(1);
- $exp->log_stdout(1);
- $exp->expect(2,[
- qr/password:/i,
- sub {
- my $exp = shift ;
- $exp->send("$pass\n");
- exp_continue;
- }
- ],
- [
- 'connecting (yes/no)?',
- sub {
- my $exp = shift ;
- $exp->send("yes\n");
- }
- ]
- );
- [bankdplyop@cnsz040545 unix_deploy]$ auto2
- Starting EXPECT pattern matching...
- at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561
- Expect::expect('Expect=GLOB(0xa64baa0)', 2, 'ARRAY(0xa64c230)', 'ARRAY(0xa64c280)') called at ./auto2 line 39
- spawn id(3): list of patterns:
- #1: -re `(?i-xsm:password:)'
- #2: -re `connecting (yes/no)?'
- spawn id(3): Does `'
- match:
- pattern #1: -re `(?i-xsm:password:)'? No.
- pattern #2: -re `connecting (yes/no)?'? No.
- The authenticity of host '10.8.4.136 (10.8.4.136)' can't be established.
- RSA key fingerprint is 72:05:2f:55:58:ee:6f:e8:fa:36:69:cc:24:ec:d1:24.
- Are you sure you want to continue connecting (yes/no)?
- spawn id(3): Does `The authenticity of host \'10.8.4.136 (10.8.4.136)\' can\'t be established.\r\nRSA key fingerprint is 72:05:2f:55:58:ee:6f:e8:fa:36:69:cc:24:ec:d1:24.\r\nAre you sure you want to continue connecting (yes/no)? '
- match:
- pattern #1: -re `(?i-xsm:password:)'? No.
- pattern #2: -re `connecting (yes/no)?'? YES!!
- Before match string: `The authenticity of host \'10.8.4.136 (10.8.4.136)\' can\'t be established.\r\nRSA key fingerprint is 72:05:2f:55:58:ee:6f:e8:fa:36:69:cc:24:ec:d1:24.\r\nAre you sure you want to continue '
- Match string: `connecting '
- After match string: `(yes/no)? '
- Matchlist: (`')
- Calling hook CODE(0xa57a060)...
- Sending 'yes\n' to spawn id(3)
- at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 1267
- Expect::print('Expect=GLOB(0xa64baa0)', 'yes\x{a}') called at ./auto2 line 36
- main::__ANON__('Expect=GLOB(0xa64baa0)') called at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 760
- Expect::_multi_expect(2, 'undef', 'ARRAY(0xa64c4d0)') called at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 565
- Expect::expect('Expect=GLOB(0xa64baa0)', 2, 'ARRAY(0xa64c230)', 'ARRAY(0xa64c280)') called at ./auto2 line 39
- Sending '\003' to spawn id(3)
- at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 1267
- Expect::print('Expect=GLOB(0xa64baa0)', '\x{3}') called at ./auto2 line 42
- Starting EXPECT pattern matching...
- at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561
- Expect::expect('Expect=GLOB(0xa64baa0)', 2) called at ./auto2 line 43
- spawn id(3): list of patterns:
- spawn id(3): Does `(yes/no)? '
- match:
- Starting EXPECT pattern matching...
- at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561
- Expect::expect('Expect=GLOB(0xa64baa0)', 1, '$passwd') called at ./auto2 line 45
- spawn id(3): list of patterns:
- #1: -ex `$passwd'
- spawn id(3): Does `'
- match:
- pattern #1: -ex `$passwd'? No.
- Starting EXPECT pattern matching...
- at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561
- Expect::expect('Expect=GLOB(0xa64baa0)', 2) called at ./auto2 line 47
- spawn id(3): list of patterns:
- spawn id(3): Does `'
- match:
- fcntl returned undef during exp_init of Expect=GLOB(0xa64baa0), 錯誤的文件描述符
復制代碼 |
|