亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
12下一頁
最近訪問板塊 發(fā)新帖
查看: 4751 | 回復: 14
打印 上一主題 下一主題

【求助】perl expect 登陸問題 [復制鏈接]

論壇徽章:
0
跳轉到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2010-08-11 18:37 |只看該作者 |倒序瀏覽
本帖最后由 yanzy 于 2010-08-12 14:49 編輯

有時候匹配得過去,有時候匹配不過去得,請大俠幫忙
問題在這一塊Are you sure you want to continue connecting (yes/no)?

  1. #!/usr/bin/perl
  2.   use Expect;

  3. $ENV{TERM} = "vt100";

  4.        my @server_ip=('10.8.4.136');
  5.        my $ip=@_;
  6.      # my $exp = Expect->new;


  7. foreach $ip(@server_ip){
  8.      my $timeout = 2;
  9.      my $pass="Paic1234";
  10.    

  11.     $exp = Expect->spawn("ssh -l yanzy $ip");
  12.     $exp->log_file("output.log");

  13.    $exp->exp_internal(1);
  14.    $exp->log_stdout(1);

  15.     $exp->expect(2,[
  16.                  qr/password:/i,
  17.          sub {
  18.                my $exp = shift ;
  19.                $exp->send("$pass\n");
  20.                exp_continue;
  21.              }

  22.                  ],

  23.                 [
  24.                     'connecting (yes/no)?',
  25.                     sub {
  26.                       my $exp = shift ;
  27.                       $exp->send("yes\n");

  28.                         }
  29.                 ]

  30.               );


  31. [bankdplyop@cnsz040545 unix_deploy]$ auto2
  32. Starting EXPECT pattern matching...
  33. at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561
  34.         Expect::expect('Expect=GLOB(0xa64baa0)', 2, 'ARRAY(0xa64c230)', 'ARRAY(0xa64c280)') called at ./auto2 line 39
  35. spawn id(3): list of patterns:
  36.   #1: -re `(?i-xsm:password:)'
  37.   #2: -re `connecting (yes/no)?'


  38. spawn id(3): Does `'
  39. match:
  40.   pattern #1: -re `(?i-xsm:password:)'? No.
  41.   pattern #2: -re `connecting (yes/no)?'? No.

  42. The authenticity of host '10.8.4.136 (10.8.4.136)' can't be established.
  43. RSA key fingerprint is 72:05:2f:55:58:ee:6f:e8:fa:36:69:cc:24:ec:d1:24.
  44. Are you sure you want to continue connecting (yes/no)?
  45. 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)? '
  46. match:
  47.   pattern #1: -re `(?i-xsm:password:)'? No.
  48.   pattern #2: -re `connecting (yes/no)?'? YES!!
  49.     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 '
  50.     Match string: `connecting '
  51.     After match string: `(yes/no)? '
  52.     Matchlist: (`')
  53. Calling hook CODE(0xa57a060)...
  54. Sending 'yes\n' to spawn id(3)
  55. at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 1267
  56.         Expect::print('Expect=GLOB(0xa64baa0)', 'yes\x{a}') called at ./auto2 line 36
  57.         main::__ANON__('Expect=GLOB(0xa64baa0)') called at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 760
  58.         Expect::_multi_expect(2, 'undef', 'ARRAY(0xa64c4d0)') called at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 565
  59.         Expect::expect('Expect=GLOB(0xa64baa0)', 2, 'ARRAY(0xa64c230)', 'ARRAY(0xa64c280)') called at ./auto2 line 39
  60. Sending '\003' to spawn id(3)
  61. at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 1267
  62.         Expect::print('Expect=GLOB(0xa64baa0)', '\x{3}') called at ./auto2 line 42
  63. Starting EXPECT pattern matching...
  64. at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561
  65.         Expect::expect('Expect=GLOB(0xa64baa0)', 2) called at ./auto2 line 43
  66. spawn id(3): list of patterns:


  67. spawn id(3): Does `(yes/no)? '
  68. match:

  69. Starting EXPECT pattern matching...
  70. at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561
  71.         Expect::expect('Expect=GLOB(0xa64baa0)', 1, '$passwd') called at ./auto2 line 45
  72. spawn id(3): list of patterns:
  73.   #1: -ex `$passwd'


  74. spawn id(3): Does `'
  75. match:
  76.   pattern #1: -ex `$passwd'? No.

  77. Starting EXPECT pattern matching...
  78. at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561
  79.         Expect::expect('Expect=GLOB(0xa64baa0)', 2) called at ./auto2 line 47
  80. spawn id(3): list of patterns:


  81. spawn id(3): Does `'
  82. match:

  83. fcntl returned undef during exp_init of Expect=GLOB(0xa64baa0), 錯誤的文件描述符
復制代碼

論壇徽章:
0
2 [報告]
發(fā)表于 2010-08-11 21:51 |只看該作者
為什么 第二個'connecting (yes/no)? 匹配沒有exp_continue? 而且匹配connecting (yes/no)也不能這么寫吧,看是不是需要轉義

論壇徽章:
0
3 [報告]
發(fā)表于 2010-08-12 14:28 |只看該作者
有時候就匹配過去了··很奇怪呢

論壇徽章:
0
4 [報告]
發(fā)表于 2010-08-12 14:37 |只看該作者
重貼一下,你這個圖標太多不想看

論壇徽章:
0
5 [報告]
發(fā)表于 2010-08-12 14:49 |只看該作者
已經(jīng)重新編輯了下,請高手指點下

論壇徽章:
0
6 [報告]
發(fā)表于 2010-08-12 15:58 |只看該作者
‘connecting (yes/no)? ’
  對應的sub語句完事后,sleep下,可能是運算響應問題

論壇徽章:
0
7 [報告]
發(fā)表于 2010-08-12 16:41 |只看該作者
將sleep設置到了10秒以上  幾率為二分之一。

論壇徽章:
0
8 [報告]
發(fā)表于 2010-08-12 16:50 |只看該作者
是設置在send yes的前面還是后面?

論壇徽章:
0
9 [報告]
發(fā)表于 2010-08-12 16:57 |只看該作者
$exp->send("yes\n");

在send得后面

論壇徽章:
0
10 [報告]
發(fā)表于 2010-08-12 17:13 |只看該作者
應該設置在前面,我之前遇到過類似的錯誤,不知道我們的是不是一樣。
分析問題很可能在于,出現(xiàn)(yes/no)的提示后你立刻去send  yes,而這時被登錄機器那邊還沒有完全準備好接收yes,所以算是輸入錯誤,又重現(xiàn)出現(xiàn)(yes/no),。如此反復........
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術有限公司. 版權所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關心和支持過ChinaUnix的朋友們 轉載本站內容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP