[ale] [OT] Perl Question

Chris Fowler cfowler at outpostsentinel.com
Tue Mar 18 17:25:52 EST 2003


Wow that is spaghetti like.  Expect is awesome for tasks like this.


On Tue, 2003-03-18 at 15:59, Jonathan Glass wrote:
> I'm using Net::Telnet to connect to a 3Com 3300 Switch.  I'm trying to
> execute a command at the "Select menu option:" command line.  The script
> successfully connects, but the command keeps timing out.  Here is the
> code, input and output logs, and debug log.
> 
> TIA
> 
> -----test.pl-----
> #!/usr/bin/perl
> use Net::Telnet ();
> $username = "monitor";
> $passwd = "monitor";
> $t = new Net::Telnet (Timeout => 20,
>     Dump_log => "/home/jglass/perl/perl-dump.log",
>     Input_log => "/home/jglass/perl/perl-debug-input.log",
>     Output_log => "/home/jglass/perl/perl-debug-output.log",
>     Host => "switch ip address",
>     Prompt => '/^Login*$/');
>     $t->open();
> #   $t->waitfor('/^$/');
>     $t->print('\n');
>     $t->print('\n');
>     $t->login($username, $passwd);
>     $t->waitfor('/---$/');
>     $t->print('\n');
>    # $t->prompt('/Select menu option: $/');
>     @lines = $t->cmd("bridge port address find <mac address>");
>     $t->print('logout');
>     print @lines;
> 
> ----end test.pl----
> 
> ---perl-debug-input.log---
> \n
> 
> 
> Login: monitor
> Password:
> 
> Menu options: --------------^[[1m3Com SuperStack II Switch
> 3300^[[0m--------------
>  bridge             - Administer bridging/VLANS
>  ethernet           - Administer Ethernet ports
>  feature            - Administer system features
>  ip                 - Administer IP
>  logout             - Logout of the Command Line Interface
>  snmp               - Administer SNMP
>  system             - Administer system-level functions
> 
> Type ? for help.
> --------------------------------^[[3300 (4 units)
> (1)^[[0m------------------
> Select menu option:
> ---end perl-debug-input.log---
> 
> ---perl-dump.log---
> > 0x00000: 5c 6e 0d 0a                                         \n..
> 
> > 0x00000: 5c 6e 0d 0a                                         \n..
> 
> < 0x00000: ff fd 03                                            ??.
> 
> > 0x00000: ff fc 03                                            ??.
> 
> < 0x00000: ff fb 03 ff  fb 01 5c 6e  0d 0a                    
> ??.??.\n..
> 
> > 0x00000: ff fd 03 ff  fd 01                                  ??.??.
> 
> < 0x00000: ff fe 03                                            ??.
> 
> < 0x00000: 0d 0a                                               ..
> 
> < 0x00000: 0d 0a 4c 6f  67 69 6e 3a  20                        ..Login:
> 
> > 0x00000: 6d 6f 6e 69  74 6f 72 0d  0a                        monitor..
> 
> < 0x00000: 6d                                                  m
> 
> < 0x00000: 6f 6e 69 74  6f 72 0d 0a  50 61 73 73  77 6f 72 64 
> onitor..Password
> < 0x00010: 3a 20                                               :
> 
> > 0x00000: 6d 6f 6e 69  74 6f 72 0d  0a                        monitor..
> 
> < 0x00000: 0d 0a                                               ..
> 
> < 0x00000: 0d 0a 4d 65  6e 75 20 6f  70 74 69 6f  6e 73 3a 20  ..Menu
> options:
> < 0x00010: 2d 2d 2d 2d  2d 2d 2d 2d  2d 2d 2d 2d  2d 2d 1b 5b 
> --------------.[
> < 0x00020: 31 6d 33 43  6f 6d 20 53  75 70 65 72  53 74 61 63  1m3Com
> SuperStac
> < 0x00030: 6b 20 49 49  20 53 77 69  74 63 68 20  33 33 30 30  k II
> Switch 3300
> < 0x00040: 1b 5b 30 6d  2d 2d 2d 2d  2d 2d 2d 2d  2d 2d 2d 2d 
> .[0m------------
> < 0x00050: 2d 2d 0d 0a                                         --..
> 
> < 0x00000: 20 62 72 69  64 67 65 20  20 20 20 20  20 20 20 20   bridge
> < 0x00010: 20 20 20 20  2d 20 41 64  6d 69 6e 69  73 74 65 72      -
> Administer
> < 0x00020: 20 62 72 69  64 67 69 6e  67 2f 56 4c  41 4e 53 0d  
> bridging/VLANS.
> < 0x00030: 0a                                                  .
> 
> < 0x00000: 20 65 74 68  65 72 6e 65  74 20 20 20  20 20 20 20   ethernet
> < 0x00010: 20 20 20 20  2d 20 41 64  6d 69 6e 69  73 74 65 72      -
> Administer
> < 0x00020: 20 45 74 68  65 72 6e 65  74 20 70 6f  72 74 73 0d   Ethernet
> ports.
> < 0x00030: 0a                                                  .
> 
> < 0x00000: 20 66 65 61  74 75 72 65  20 20 20 20  20 20 20 20   feature
> < 0x00010: 20 20 20 20  2d 20 41 64  6d 69 6e 69  73 74 65 72      -
> Administer
> < 0x00020: 20 73 79 73  74 65 6d 20  66 65 61 74  75 72 65 73   system
> features
> < 0x00030: 0d 0a                                               ..
> 
> < 0x00000: 20 69 70 20  20 20 20 20  20 20 20 20  20 20 20 20   ip
> < 0x00010: 20 20 20 20  2d 20 41 64  6d 69 6e 69  73 74 65 72      -
> Administer
> < 0x00020: 20 49 50 0d  0a                                      IP..
> 
> < 0x00000: 20 6c 6f 67  6f 75 74 20  20 20 20 20  20 20 20 20   logout
> < 0x00010: 20 20 20 20  2d 20 4c 6f  67 6f 75 74  20 6f 66 20      -
> Logout of
> < 0x00020: 74 68 65 20  43 6f 6d 6d  61 6e 64 20  4c 69 6e 65  the
> Command Line
> < 0x00030: 20 49 6e 74  65 72 66 61  63 65 0d 0a               
> Interface..
> 
> < 0x00000: 20 73 6e 6d  70 20 20 20  20 20 20 20  20 20 20 20   snmp
> < 0x00010: 20 20 20 20  2d 20 41 64  6d 69 6e 69  73 74 65 72      -
> Administer
> < 0x00020: 20 53 4e 4d  50 0d 0a                                SNMP..
> 
> < 0x00000: 20 73 79 73  74 65 6d 20  20 20 20 20  20 20 20 20   system
> < 0x00010: 20 20 20 20  2d 20 41 64  6d 69 6e 69  73 74 65 72      -
> Administer
> < 0x00020: 20 73 79 73  74 65 6d 2d  6c 65 76 65  6c 20 66 75  
> system-level fu
> < 0x00030: 6e 63 74 69  6f 6e 73 0d  0a                        nctions..
> 
> < 0x00000: 0d 0a 54 79  70 65 20                               ..Type
> 
> < 0x00000: 3f 20 66 6f  72 20 68 65  6c 70 2e 0d  0a           ? for
> help...
> 
> < 0x00000: 2d 2d 2d 2d  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: 1b 5b 31 6d  49 42 42 20  33 33 30 30  20 28 34 20  .[3300 (4
> < 0x00030: 75 6e 69 74  73 29 20 28  31 29 1b 5b  30 6d 2d 2d  units)
> (1).[0m--
> < 0x00040: 2d 2d 2d 2d  2d 2d 2d 2d  2d 2d 2d 2d  2d 2d 2d 2d 
> ----------------
> 
> < 0x00000: 0d 0a 53 65  6c 65 63 74  20 6d 65 6e  75 20 6f 70  ..Select
> menu op
> < 0x00010: 74 69 6f 6e  3a 20                                  tion:
> 
> ------end perl-dump.log------
> -- 
> Jonathan Glass
> Systems Support Specialist II
> Institute for Bioengineering & Bioscience
> Georgia Institute of Technology
> 404.385.0127


_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale






More information about the Ale mailing list