Hi,

Script is executing and once it enters the Function "cmd_previlege", it fails there saying "command timed-out at ***.pl line 281 <-- this is nothing but the line ### @outputforlog = $session->cmd(String => 'show ip ospf neighbor det | in Neighbor | in up', Prompt => '/\#2#/'); ####

Is it failing at the session prompt request ? -- It is logging into device and executing the command ---> ##### @outputforlog = $session->cmd(String => 'show ip ospf neighbor det | in Neighbor | in up', Prompt => '/\#2#/'); ### from cmd_previlege funtion, then it fails. It doesnt execute further. I came to know of this through log files.

Snippet of in.log files

$ cat in.log

#############################################################################

#############################################################################

Warning! Only Network Administrator can log in this router!

Unauthorized access can be punished by law

Jun Won, Lee : 02-3415-6757

Mi Sun, Jeong : 02-3415-6727

#############################################################################

username:to27

password:

------------------------------

6F X03 PWR#1(6K) - UPS 500-1A * 2

PWR#2(6K) - UPS 500-1B * 2

------------------------------ SES_Main#2#show ip ospf neighbor det | in Neighbor | in up

Neighbor 10.21.157.2, interface address 10.21.157.194

Neighbor priority is 0, State is FULL, 6 state changes

Neighbor is up for 7w6d

Neighbor 10.22.46.2, interface address 10.22.46.194

Neighbor priority is 0, State is FULL, 6 state changes

Neighbor is up for 7w6d

.

.

.

Neighbor 123.11.4.2, interface address 10.20.3.25

Neighbor priority is 1, State is FULL, 6 state changes

Neighbor is up for 7w3d

Neighbor 193.9.20.4, interface address 193.9.14.2

Neighbor priority is 1, State is FULL, 6 state changes

Neighbor is up for 11w3d

Neighbor 193.9.16.4, interface address 193.9.15.6

Neighbor priority is 1, State is FULL, 6 state changes

Neighbor is up for 11w3d

SES_Main#2#

Snippet of out.log files

$ cat out.log

to27

********

show ip ospf neighbor det | in Neighbor | in up

Snippet of dump.log files

$ cat dump.log

< 0x000a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################

< 0x000b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################

< 0x000c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################

< 0x000d0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################

< 0x000e0: 23 23 23 23 23 0d 0a 0d 0a 20 20 20 20 20 20 20 #####....

< 0x000f0: 57 61 72 6e 69 6e 67 21 20 4f 6e 6c 79 20 4e 65 Warning! Only Ne

< 0x00100: 74 77 6f 72 6b 20 41 64 6d 69 6e 69 73 74 72 61 twork Administra

< 0x00110: 74 6f 72 20 63 61 6e 20 6c 6f 67 20 69 6e 20 74 tor can log in t

< 0x00120: 68 69 73 20 72 6f 75 74 65 72 21 0d 0a 0d 0a 20 his router!....

< 0x00130: 20 20 20 20 20 20 20 20 20 20 20 55 6e 61 75 74 Unaut

< 0x00140: 68 6f 72 69 7a 65 64 20 61 63 63 65 73 73 20 63 horized access c

< 0x00150: 61 6e 20 62 65 20 70 75 6e 69 73 68 65 64 20 62 an be punished b

< 0x00160: 79 20 6c 61 77 0d 0a 0d 0a 20 20 20 20 20 20 20 y law....

< 0x00170: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 53 61 Sa

< 0x00180: 6d 73 75 6e 67 20 4e 65 74 77 6f 72 6b 73 20 53 msung Networks S

< 0x00190: 45 20 33 74 68 20 54 65 61 6d 0d 0a 0d 0a 20 20 E 3th Team....

< 0x001a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20

< 0x001b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20

< 0x001c0: 20 20 20 20 20 20 4a 75 6e 20 57 6f 6e 2c 20 4c Jun Won. L

< 0x001d0: 65 65 20 20 20 20 20 20 3a 20 30 32 2d 33 34 31 ee : 02-341

< 0x001e0: 35 2d 36 37 35 37 0d 0a 20 20 20 20 20 20 20 20 5-6757..

< 0x001f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20

< 0x00200: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20

< 0x00210: 4d 69 20 53 75 6e 2c 20 4a 65 6f 6e 67 20 20 20 Mi Sun. Jeong

< 0x00220: 20 20 3a 20 30 32 2d 33 34 31 35 2d 36 37 32 37 : 02-3415-6727

< 0x00230: 0d 0a 0d 0a 23 23 23 23 23 23 23 23 23 23 23 23 ....############

< 0x00240: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################

< 0x00250: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################

< 0x00260: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################

< 0x00270: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################

< 0x00280: 23 0d 0a 75 73 65 72 6e 61 6d 65 3a #..username:

> 0x00000: ff fd 01 ff fd 03 ff fc 18 ff fc 1f ¢Æ¢Æ.¢Æ¢Æ.¢Æ¢Æ.¢Æ¢Æ.

> 0x00000: 74 6f 32 37 0d 0a to27..

< 0x00000: ff fe 18 ff fe 1f 74 6f 32 37 0d 0a 70 61 73 73 ¢Æ¢Æ.¢Æ¢Æ.to27..pass

< 0x00010: 77 6f 72 64 3a word:

> 0x00000: 68 6f 6d 65 70 6c 75 73 32 37 0d 0a ********..

< 0x00000: 0d 0a 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ....------------

< 0x00010: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------

< 0x00020: 2d 2d 0d 0a 20 20 36 46 20 58 30 33 0d 0a 0a 20 --.. 6F X03...

< 0x00030: 20 50 57 52 23 31 28 36 4b 29 20 2d 20 55 50 53 PWR#1(6K) - UPS

< 0x00040: 20 35 30 30 2d 31 41 20 2a 20 32 0d 0a 20 20 50 500-1A * 2.. P

< 0x00050: 57 52 23 32 28 36 4b 29 20 2d 20 55 50 53 20 35 WR#2(6K) - UPS 5

< 0x00060: 30 30 2d 31 42 20 2a 20 32 0d 0a 2d 2d 2d 2d 2d 00-1B * 2..-----

< 0x00070: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------

< 0x00080: 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 0d 0a 53 45 53 ---------....SES

< 0x00090: 5f 4d 61 69 6e 23 32 23 _Main#2#

> 0x00000: 73 68 6f 77 20 69 70 20 6f 73 70 66 20 6e 65 69 show ip ospf nei

> 0x00010: 67 68 62 6f 72 20 64 65 74 20 7c 20 69 6e 20 4e ghbor det | in N

> 0x00020: 65 69 67 68 62 6f 72 20 7c 20 69 6e 20 75 70 0d eighbor | in up.

> 0x00030: 0a .

.

.

.

.

.

.

< 0x002f0: 20 20 20 20 4e 65 69 67 68 62 6f 72 20 70 72 69 Neighbor pri

< 0x00300: 6f 72 69 74 79 20 69 73 20 31 2c 20 53 74 61 74 ority is 1. Stat

< 0x00310: 65 20 69 73 20 46 55 4c 4c 2c 20 36 20 73 74 61 e is FULL. 6 sta

< 0x00320: 74 65 20 63 68 61 6e 67 65 73 0d 0a 20 20 20 20 te changes..

< 0x00330: 4e 65 69 67 68 62 6f 72 20 69 73 20 75 70 20 66 Neighbor is up f

< 0x00340: 6f 72 20 31 31 77 33 64 20 20 20 0d 0a 53 45 53 or 11w3d ..SES

< 0x00350: 5f 4d 61 69 6e 23 32 23 _Main#2#

Could you please suggest me a regex for the prompt with below hostnames with previlege mode access?

1. SES_Main#1

2. SES_Main#2

3. Tesco_main#1

4. Tesco_Main#2

I tried regex as "'/(?m:^(?:\w.\/+\:)?\w.-+\s?(?:\(config^\)*\))?\s?\$#>\s?(?:\(enable\))?\s*$)/'". But no luck.


In reply to Re^2: Script to telnet to different cisco devices, but timed out at a particular statement. by bks
in thread Script to telnet to different cisco devices, but timed out at a particular statement. by bks

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.