nettelnetcisco-users Mailing List for Net::Telnet::Cisco
Brought to you by:
jkeroes
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
(2) |
Apr
(10) |
May
(5) |
Jun
(6) |
Jul
(5) |
Aug
(6) |
Sep
|
Oct
(4) |
Nov
(3) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(8) |
Feb
(1) |
Mar
(10) |
Apr
(3) |
May
(3) |
Jun
|
Jul
(3) |
Aug
(9) |
Sep
|
Oct
(15) |
Nov
(6) |
Dec
|
2004 |
Jan
|
Feb
(3) |
Mar
(3) |
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
(9) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2005 |
Jan
(2) |
Feb
(2) |
Mar
(2) |
Apr
|
May
|
Jun
(4) |
Jul
|
Aug
(2) |
Sep
(7) |
Oct
|
Nov
|
Dec
(2) |
2006 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(7) |
Oct
|
Nov
(2) |
Dec
|
2007 |
Jan
(4) |
Feb
(7) |
Mar
|
Apr
(4) |
May
(3) |
Jun
(3) |
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2008 |
Jan
|
Feb
(5) |
Mar
(2) |
Apr
|
May
(15) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2012 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Tech S. <su...@vo...> - 2019-05-18 19:44:14
|
Hello; I am using the Net::Telnet::Cisco CPAN module as part of a script to login to a Cisco router and capture the output of a couple of simple commands. The problem I am having is that it's not obvious to me how to have the script gracefully recover in the event that the login fails. For example, my $router = '192.168.2.1'; my $login = 'root'; my $password = 'badpassword'; my $session = Net::Telnet::Cisco->new( Host => $router ); my $results = $session->login($login, $password); . . .. The script itself will die at the 'login' command without proceeding to the next line. Is there a way for the script to gracefully continue without dying at that line? Any insight at all would be appreciated. Thanks; John V. |
From: Andreas, R. <Ric...@Ca...> - 2015-05-26 14:17:56
|
Look at errmode. You could call a custom error handler. For instance: my $session = Net::Telnet::Cisco->new(Host => $_, Timeout => 120, Prompt => '/(?m:^(?:[\w.\/]+\:)?[\w.-]+\s?(?:\(config[^\)]*\))?\s?[\$#>]\s?(?:\(enable\))?\s*$)/', Input_log => $ilog, Output_log => $olog, errmode => \&uhoh); # subroutine for Telnet error handling. Skips to next if problems connecting. sub uhoh { if ( $@ ne "") { print ("$@\n"); next; } else { print "Success\n"; } } From: Olivier CALVANO [mailto:o.c...@gm...] Sent: Saturday, May 23, 2015 7:56 AM To: net...@li... Subject: [Net::Telnet::Cisco users] Net::Telnet::Cisco Help Hi i have a small problems with Net::Telnet::Cisco : sub Connexion_Routeur { $session = Net::Telnet::Cisco->new(Host => "$Routeur_CE_Primaire_IP_Management", Errmode => 'return'); $session->open("$Routeur_CE_Primaire_IP_Management"); if ($session->errmsg){ print "errmsg: " . $session->errmsg . "\n";} else { &Verification_Acces_SNMP;} } this script work when the router answer, but if the routeur don't answer (bad ip, router disconnected) my script stop (die) with: Can't call method "open" on an undefined value at ./myscript.pl<http://myscript.pl> line 156. i don't want that my script stop, only print the errmsg and continue (it's a while loop) where is my error ? regards olivier |
From: Garry T. W. <gtw...@gm...> - 2015-05-23 12:39:11
|
On 5-23-15 13:55:43 Olivier CALVANO wrote: > sub Connexion_Routeur { > $session = Net::Telnet::Cisco->new(Host => "$Routeur_CE_Primaire_IP_Management", Errmode => 'return'); > $session->open("$Routeur_CE_Primaire_IP_Management"); > > if ($session->errmsg){ print "errmsg: " . $session->errmsg . "\n";} > else { &Verification_Acces_SNMP;} > } > > this script work when the router answer, but if the routeur don't > answer (bad ip, router disconnected) my script stop (die) with: > > Can't call method "open" on an undefined value at ./myscript.pl line > 156. > > i don't want that my script stop, only print the errmsg and continue > (it's a while loop) Then you must check the result from calling Net::Telnet::Cisco->new() before calling open() on it. -- Garry T. Williams |
From: Olivier C. <o.c...@gm...> - 2015-05-23 11:55:52
|
Hi i have a small problems with Net::Telnet::Cisco : sub Connexion_Routeur { $session = Net::Telnet::Cisco->new(Host => "$Routeur_CE_Primaire_IP_Management", Errmode => 'return'); $session->open("$Routeur_CE_Primaire_IP_Management"); if ($session->errmsg){ print "errmsg: " . $session->errmsg . "\n";} else { &Verification_Acces_SNMP;} } this script work when the router answer, but if the routeur don't answer (bad ip, router disconnected) my script stop (die) with: Can't call method "open" on an undefined value at ./myscript.pl line 156. i don't want that my script stop, only print the errmsg and continue (it's a while loop) where is my error ? regards olivier |
From: Nicolas K. <li...@ka...> - 2013-11-12 22:22:37
|
Hi Joshua, Thank you for your help ! I made some progress.. The problem is not related to the auto paging. The script is working fine when I use it with a Cisco device via telnet. I have some pb when i try to reach a Cisco device via a remote console device. It seems that the problem would be between the carrier return and the daemon ser2net (telnet port to serial) Every time i send a command to the TS, the Cisco device receives the command + a new line (in the input.log) so I guess the module doesn't like it.... Let me know if you think about anything :-) I'm still working on it !! Many thanks. |
From: Nicolas K. <li...@ka...> - 2013-11-12 14:27:58
|
Hi Everyone, I have a problem to get the result of my "show" command. Someone in 2005 had the same issue but unfortunately, there was no workaround provided by this list :( @A=$session->cmd(*'*COMMAND A*'*); @B=$session->cmd(*'*COMMAND B*'*); ... But sometimes @B contain what @A should contain. I would like to parse some output of "show" commands : (obviously, I put a wrong TFTP IP, just for testing..) sh ip int brief sh ver ... When I look at the file input.log, all the commands are sent to the device and process correctly... Can you please help me to resolve this issue ? Thanks. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - Nicolas KARP # - - Network and Security Engineer # - - Email : li...@ka... <ni...@ka...> # - - Linkedin : http://www.linkedin.com/in/nicolaskarp # - - Viadeo : http://www.viadeo.com/fr/profile/nicolas.karp <http://www.viadeo.com/fr/profile/nicolas.karp%20> # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
From: Burns, K. <Kev...@Ca...> - 2013-05-05 15:31:29
|
In some Cisco devices there is an invisible single control character in front of the line. IOS-XR has the same problem. On May 5, 2013, at 1:19 AM, "Stefan Leippert" <Ste...@hu...<mailto:Ste...@hu...>> wrote: Problem has been solved modifing the regex (those one checking the prompt) in Cisco.pm: Add \W? to the start of the regex Then send as first command "terminal lenght 0" Thanks to Kevin Burns for the debugging and help ! BR, stefan HUGO BOSS AG Dieselstra?e 12 D-72555 Metzingen Telefon 07123/94-0 Fax 07123/94-2014 Vorsitzender des Aufsichtsrats: Dr. Hellmut Albrecht Vorstand: Claus-Dietrich Lahrs, Vorsitzender Christoph Auhagen, Mark Langer Firmensitz: Metzingen Registergericht: Amtsgericht Stuttgart Nr. HRB 360610 This e-mail (and/or attachments) is confidential and may be privileged. Use or disclosure of it by anyone other than a designated addressee is unauthorized. If you are not an intended recipient, please delete this e-mail from the computer on which you received it. We thank you for notifying us immediately. ------------------------------------------------------------------------------ Get 100% visibility into Java/.NET code with AppDynamics Lite It's a free troubleshooting tool designed for production Get down to code-level detail for bottlenecks, with <2% overhead. Download for free and get started troubleshooting in minutes. http://p.sf.net/sfu/appdyn_d2d_ap2 _______________________________________________ NetTelnetCisco-users mailing list Net...@li...<mailto:Net...@li...> https://lists.sourceforge.net/lists/listinfo/nettelnetcisco-users |
From: Stefan L. <Ste...@hu...> - 2013-05-05 07:18:58
|
Problem has been solved modifing the regex (those one checking the prompt) in Cisco.pm: Add \W? to the start of the regex Then send as first command "terminal lenght 0" Thanks to Kevin Burns for the debugging and help ! BR, stefan HUGO BOSS AG Dieselstraße 12 D-72555 Metzingen Telefon 07123/94-0 Fax 07123/94-2014 Vorsitzender des Aufsichtsrats: Dr. Hellmut Albrecht Vorstand: Claus-Dietrich Lahrs, Vorsitzender Christoph Auhagen, Mark Langer Firmensitz: Metzingen Registergericht: Amtsgericht Stuttgart Nr. HRB 360610 This e-mail (and/or attachments) is confidential and may be privileged. Use or disclosure of it by anyone other than a designated addressee is unauthorized. If you are not an intended recipient, please delete this e-mail from the computer on which you received it. We thank you for notifying us immediately. |
From: Burns, K. <Kev...@Ca...> - 2013-04-22 15:52:59
|
Are you able to get past the login/password prompt? Chances are you are not matching some prompt correctly. $session->login(Name => $username, Password => $password, Prompt => '/(?m:^\W?[\w\/\d.:-]+[>#])/') or die "Login failure to $devip $1\n" }; The above prompt regex is just an example. You will have to figure it out yourself. If you send me the login/password prompt and the successful login prompt I can help you. From: Stefan Leippert [mailto:Ste...@hu...] Sent: Monday, April 22, 2013 7:11 AM To: net...@li... Subject: [Net::Telnet::Cisco users] Login to Cisco Nexus 7000 - timeout problem Hi together, sorry to bother with a timeout problem. We use Net::Telnet::Cisco to locate which MACs are located on which switch. Worked perfectly on our 6509-Infrastructure. On the new Nexus 7000 we run immediatly into timeout problems after/during login: Code snippet: $device_object = Net::Telnet::Cisco->new( Host => $DEVICE, Dump_Log => "dumplog.log", Input_log=>"inputlog.log"); dumplog.log: < 0x00000: 42 61 64 20 74 65 72 6d 69 6e 61 6c 20 74 79 70 Bad terminal typ < 0x00010: 65 3a 20 22 6e 65 74 77 6f 72 6b 22 2e 20 57 69 e: "network". Wi < 0x00020: 6c 6c 20 61 73 73 75 6d 65 20 76 74 31 30 30 2e ll assume vt100. < 0x00030: 0d 0a .. < 0x00000: 43 69 73 63 6f 20 4e 65 78 75 73 20 4f 70 65 72 Cisco Nexus Oper < 0x00010: 61 74 69 6e 67 20 53 79 73 74 65 6d 20 28 4e 58 ating System (NX < 0x00020: 2d 4f 53 29 20 53 6f 66 74 77 61 72 65 0d 0a 54 -OS) Software..T < 0x00030: 41 43 20 73 75 70 70 6f 72 74 3a 20 68 74 74 70 AC support: http < 0x00040: 3a 2f 2f .... < 0x00010: 2e 30 2e 70 68 70 20 61 6e 64 0d 0a 68 74 74 70 .0.php and..http < 0x00020: 3a 2f 2f 77 77 77 2e 6f 70 65 6e 73 6f 75 72 63 ://www.opensourc < 0x00030: 65 2e 6f 72 67 2f 6c 69 63 65 6e 73 65 73 2f 6c e.org/licenses/l < 0x00040: 67 70 6c 2d 32 2e 31 2e 70 68 70 0d 0a gpl-2.1.php.. < 0x00000: 0d 00 68 62 6d 65 6e 73 30 31 2d 31 2d 41 43 23 ..HOSTNAME# < 0x00010: 20 inputlog.log: license. Certain components of this software are licensed under the GNU General Public License (GPL) version 2.0 or the GNU Lesser General Public License (LGPL) Version 2.1. A copy of each such license is available at http://www.opensource.org/licenses/gpl-2.0.php and http://www.opensource.org/licenses/lgpl-2.1.php ^MHostname# Timeout-message is: pattern match timed-out at /usr/local/admin/mac-search.pl line 250 hbmesl1i:/usr/lib/perl5/site_perl/5.12.1/Net/Telnet # vi /usr/local/admin/mac-search.pl Line 250 is the code snippet from above. Anybody has/had similar problems on Cisco Nexus 7000 ? More infos needed? Thanks and best regards stefan HUGO BOSS AG Dieselstra?e 12 D-72555 Metzingen Telefon 07123/94-0 Fax 07123/94-2014 Vorsitzender des Aufsichtsrats: Dr. Hellmut Albrecht Vorstand: Claus-Dietrich Lahrs, Vorsitzender Christoph Auhagen, Mark Langer Firmensitz: Metzingen Registergericht: Amtsgericht Stuttgart Nr. HRB 360610 This e-mail (and/or attachments) is confidential and may be privileged. Use or disclosure of it by anyone other than a designated addressee is unauthorized. If you are not an intended recipient, please delete this e-mail from the computer on which you received it. We thank you for notifying us immediately. |
From: Stefan L. <Ste...@hu...> - 2013-04-22 13:29:18
|
Hi together, sorry to bother with a timeout problem. We use Net::Telnet::Cisco to locate which MACs are located on which switch. Worked perfectly on our 6509-Infrastructure. On the new Nexus 7000 we run immediatly into timeout problems after/during login: Code snippet: $device_object = Net::Telnet::Cisco->new( Host => $DEVICE, Dump_Log => "dumplog.log", Input_log=>"inputlog.log"); dumplog.log: < 0x00000: 42 61 64 20 74 65 72 6d 69 6e 61 6c 20 74 79 70 Bad terminal typ < 0x00010: 65 3a 20 22 6e 65 74 77 6f 72 6b 22 2e 20 57 69 e: "network". Wi < 0x00020: 6c 6c 20 61 73 73 75 6d 65 20 76 74 31 30 30 2e ll assume vt100. < 0x00030: 0d 0a .. < 0x00000: 43 69 73 63 6f 20 4e 65 78 75 73 20 4f 70 65 72 Cisco Nexus Oper < 0x00010: 61 74 69 6e 67 20 53 79 73 74 65 6d 20 28 4e 58 ating System (NX < 0x00020: 2d 4f 53 29 20 53 6f 66 74 77 61 72 65 0d 0a 54 -OS) Software..T < 0x00030: 41 43 20 73 75 70 70 6f 72 74 3a 20 68 74 74 70 AC support: http < 0x00040: 3a 2f 2f .... < 0x00010: 2e 30 2e 70 68 70 20 61 6e 64 0d 0a 68 74 74 70 .0.php and..http < 0x00020: 3a 2f 2f 77 77 77 2e 6f 70 65 6e 73 6f 75 72 63 ://www.opensourc < 0x00030: 65 2e 6f 72 67 2f 6c 69 63 65 6e 73 65 73 2f 6c e.org/licenses/l < 0x00040: 67 70 6c 2d 32 2e 31 2e 70 68 70 0d 0a gpl-2.1.php.. < 0x00000: 0d 00 68 62 6d 65 6e 73 30 31 2d 31 2d 41 43 23 ..HOSTNAME# < 0x00010: 20 inputlog.log: license. Certain components of this software are licensed under the GNU General Public License (GPL) version 2.0 or the GNU Lesser General Public License (LGPL) Version 2.1. A copy of each such license is available at http://www.opensource.org/licenses/gpl-2.0.php and http://www.opensource.org/licenses/lgpl-2.1.php ^MHostname# Timeout-message is: pattern match timed-out at /usr/local/admin/mac-search.pl line 250 hbmesl1i:/usr/lib/perl5/site_perl/5.12.1/Net/Telnet # vi /usr/local/admin/mac-search.pl Line 250 is the code snippet from above. Anybody has/had similar problems on Cisco Nexus 7000 ? More infos needed? Thanks and best regards stefan HUGO BOSS AG Dieselstraße 12 D-72555 Metzingen Telefon 07123/94-0 Fax 07123/94-2014 Vorsitzender des Aufsichtsrats: Dr. Hellmut Albrecht Vorstand: Claus-Dietrich Lahrs, Vorsitzender Christoph Auhagen, Mark Langer Firmensitz: Metzingen Registergericht: Amtsgericht Stuttgart Nr. HRB 360610 This e-mail (and/or attachments) is confidential and may be privileged. Use or disclosure of it by anyone other than a designated addressee is unauthorized. If you are not an intended recipient, please delete this e-mail from the computer on which you received it. We thank you for notifying us immediately. |
From: Phibee N. O. C. <no...@ph...> - 2012-08-09 09:51:30
|
Hi I use Net:Telnet:Cisco on one of my perl script: my $session = Net::Telnet::Cisco->new(Host => "$IPduPECollecte", Errmode => 'return'); $session->login("$Telnet_Login", '$Password'); # Enable mode if ($session->enable("$EnablePassword") ) { @output = $session->cmd("show users \| include $login_sans_realm"); $resultat = $output[0]; print ("Resultat = $resultat\n"); } My Problems: Il y put on the router the cmd show ussers | incl mylogin, i have: Vi15 mylogin@ppp PPPoVPDN 00:00:00 10.220.10.144 But my script put $resultat at "" I think's that he have a special caracteres at the line begin, what is the solution ? thanks Jerome |
From: nanda p. r. p. <ani...@gm...> - 2012-08-01 05:37:24
|
Hi, i want to capture some output from those 50 devices like in this list term length 0 term width 0 show ip interface brief show interface desc show cdp neighbo Sh processes cpu Sh platform hardware capacity cpu Sh memory summary Sh mpls l2 vc Sh l2vpn xconnect Sh l2vpn bridge-domain Sh ip vrf int Sh ip bgp vpnv4 all summary Sh bgp all Sh run | include interface|ingress|egress show clock show run show platform admin show platform show inventory admin show inventory show envi all admin show envi all show logging my friend said that you can do this easily by perl script, can i got some help to make script for capturing those devices Thanks, Animus |
From: Cletus S. <sc...@ya...> - 2012-01-02 23:11:31
|
Good day Would you also be intrested in a VB script one that you can run from your windows Computer. Cletus just remnber your thoughts are the architects of your destiny ITS THE YEAR OF THE MONKEY 2008! Yamikani --- On Sun, 12/4/11, Mik J <mik...@ya...> wrote: From: Mik J <mik...@ya...> Subject: [Net::Telnet::Cisco users] Re : Net::Telnet::Cisco => errmode not work ? To: "Olivier CALVANO" <o.c...@gm...>, "net...@li..." <net...@li...> Date: Sunday, December 4, 2011, 12:50 AM Euuhhh, Olivier, I answer in english.The output is put in an array: @outputBut you print only the first line: $output[0]Nothing abnormal Try $resultat0 = $output[0]; $resultat1 = $output[1]; thenprint ("$resultat0\n");print ("$resultat1\n"); It will now print two lines =) In conclusion, you need to parse all the lines from your array Bon week end De : Olivier CALVANO <o.c...@gm...> À : net...@li... Envoyé le : Samedi 3 Décembre 2011 21h33 Objet : [Net::Telnet::Cisco users] Net::Telnet::Cisco => errmode not work ? Hi we have a small perl script for sent a 'sh ver' on a routers: my $session = Net::Telnet::Cisco->new(Host => "172.16.1.1", Errmode => "return"); $session->login("MyLogin", 'xxxxxxxxxxxx'); # Enable mode if ($session->enable("xxxxxxxxxxx") ) { @output = $session->cmd("show ver"); $resultat = $output[0]; $session->close; } print ("$resultat\n"); my problems: i don't see all line: [root@server scripts]# ./shver.pl Cisco IOS Software, C870 Software (C870-ADVIPSERVICESK9-M), Version 12.4(24)T1, RELEASE SOFTWARE (fc3) [root@server scripts]# Same with a show ip bgp sum: [root@server scripts]# ./shipbgpsum.pl BGP router identifier 172.16.1.1, local AS number 65550 [root@server scripts]# Any one know why ? Thanks for your help Olivier ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d _______________________________________________ NetTelnetCisco-users mailing list Net...@li... https://lists.sourceforge.net/lists/listinfo/nettelnetcisco-users -----Inline Attachment Follows----- ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d -----Inline Attachment Follows----- _______________________________________________ NetTelnetCisco-users mailing list Net...@li... https://lists.sourceforge.net/lists/listinfo/nettelnetcisco-users |
From: Chris M. <ch...@si...> - 2011-12-06 09:09:21
|
Your perl is only outputting the first entry in the array you've created. $output[0] references the first "index" value in the array stack. If you're looking to see all the output lines, you might want to try something like this: === foreach my $line(@output){ chomp($line); print "$line\n"; } === Then you'll "iterate" through the entire array and output each line rather than just the very first one. -Chris (and for those perl folk that ask "why chomp when you just add a newline upon output"...let's just say it saves me a lot of WEIRD output a times so it's become a habit to ALWAYS chomp) ;o) On 12/3/11 3:33 PM, Olivier CALVANO wrote: > Hi > > we have a small perl script for sent a 'sh ver' on a routers: > > > my $session = Net::Telnet::Cisco->new(Host => "172.16.1.1", Errmode => > "return"); > > $session->login("MyLogin", 'xxxxxxxxxxxx'); > > # Enable mode > if ($session->enable("xxxxxxxxxxx") ) { > @output = $session->cmd("show ver"); > $resultat = $output[0]; > $session->close; > } > print ("$resultat\n"); > > > my problems: i don't see all line: > > [root@server scripts]# ./shver.pl <http://shver.pl> > Cisco IOS Software, C870 Software (C870-ADVIPSERVICESK9-M), Version > 12.4(24)T1, RELEASE SOFTWARE (fc3) > > [root@server scripts]# > > > Same with a show ip bgp sum: > > [root@server scripts]# ./shipbgpsum.pl <http://shipbgpsum.pl> > BGP router identifier 172.16.1.1, local AS number 65550 > > [root@server scripts]# > > > > > Any one know why ? > > Thanks for your help > Olivier > > > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure > contains a definitive record of customers, application performance, > security threats, fraudulent activity, and more. Splunk takes this > data and makes sense of it. IT sense. And common sense. > http://p.sf.net/sfu/splunk-novd2d > > > _______________________________________________ > NetTelnetCisco-users mailing list > Net...@li... > https://lists.sourceforge.net/lists/listinfo/nettelnetcisco-users |
From: Mik J <mik...@ya...> - 2011-12-03 22:50:53
|
Euuhhh, Olivier, I answer in english. The output is put in an array: @output But you print only the first line: $output[0] Nothing abnormal Try $resultat0 = $output[0]; $resultat1 = $output[1]; then print ("$resultat0\n"); print ("$resultat1\n"); It will now print two lines =) In conclusion, you need to parse all the lines from your array Bon week end >________________________________ > De : Olivier CALVANO <o.c...@gm...> >À : net...@li... >Envoyé le : Samedi 3 Décembre 2011 21h33 >Objet : [Net::Telnet::Cisco users] Net::Telnet::Cisco => errmode not work ? > > >Hi > >we have a small perl script for sent a 'sh ver' on a routers: > > >my $session = Net::Telnet::Cisco->new(Host => "172.16.1.1", Errmode => "return"); > >$session->login("MyLogin", 'xxxxxxxxxxxx'); > ># Enable mode >if ($session->enable("xxxxxxxxxxx") ) { > @output = $session->cmd("show ver"); > $resultat = $output[0]; > $session->close; >} >print ("$resultat\n"); > > >my problems: i don't see all line: > >[root@server scripts]# ./shver.pl >Cisco IOS Software, C870 Software (C870-ADVIPSERVICESK9-M), Version 12.4(24)T1, RELEASE SOFTWARE (fc3) > >[root@server scripts]# > > >Same with a show ip bgp sum: > >[root@server scripts]# ./shipbgpsum.pl >BGP router identifier 172.16.1.1, local AS number 65550 > >[root@server scripts]# > > > > >Any one know why ? > >Thanks for your help >Olivier > > >------------------------------------------------------------------------------ >All the data continuously generated in your IT infrastructure >contains a definitive record of customers, application performance, >security threats, fraudulent activity, and more. Splunk takes this >data and makes sense of it. IT sense. And common sense. >http://p.sf.net/sfu/splunk-novd2d >_______________________________________________ >NetTelnetCisco-users mailing list >Net...@li... >https://lists.sourceforge.net/lists/listinfo/nettelnetcisco-users > > > |
From: Olivier C. <o.c...@gm...> - 2011-12-03 20:33:22
|
Hi we have a small perl script for sent a 'sh ver' on a routers: my $session = Net::Telnet::Cisco->new(Host => "172.16.1.1", Errmode => "return"); $session->login("MyLogin", 'xxxxxxxxxxxx'); # Enable mode if ($session->enable("xxxxxxxxxxx") ) { @output = $session->cmd("show ver"); $resultat = $output[0]; $session->close; } print ("$resultat\n"); my problems: i don't see all line: [root@server scripts]# ./shver.pl Cisco IOS Software, C870 Software (C870-ADVIPSERVICESK9-M), Version 12.4(24)T1, RELEASE SOFTWARE (fc3) [root@server scripts]# Same with a show ip bgp sum: [root@server scripts]# ./shipbgpsum.pl BGP router identifier 172.16.1.1, local AS number 65550 [root@server scripts]# Any one know why ? Thanks for your help Olivier |
From: doug f. <dfi...@gm...> - 2010-06-11 15:07:52
|
Helping the network guys who need to change the netbios name server on a bunch of routers. Perl script runs fine, but times out on the “ip dhcp pool 1” line 28 (see excerpt below ) I can login to the switch and run these commands manually and it works fine. Any idea how I can keep it from timing out on Line 28 ? thanks. # ./netbios.pl Enter configuration commands, one per line. End with CNTL/Z. command timed-out at ./netbios.pl line 28 ( code excerpt) @output = $session->cmd('configure terminal'); print @output; @output = $session->cmd('ip dhcp pool 1'); (this is line 28 ) print @output; @output = $session->cmd('netbios-name-server 10.0.32.200 10.201.0.200'); print @output; # In order to write ^Z you have to press Ctrl+V and Ctrl+Z @output = $session->cmd('^Z'); @output = $session->cmd('write memory'); print @output; $session->close; |
From: Garrett S. <ga...@sk...> - 2009-12-04 15:36:35
|
Yes, I'm having an issue with the prompt detecting my entering an "object-group" on a Cisco ASA. Is there updated syntax for this? or perhaps an appropriate cmd for this? Or perhaps I'm barking up the wrong tree? -Garrett |
From: Chris K. <bo...@gm...> - 2008-12-12 22:09:10
|
Right or wrong, I fixed my prompt detection issue was fixed by changing the prompt regex from: '/(?m:^[\w.-]+\s?(?:\(config[^\)]*\))?\s?[\$#>]\s?(?:\(enable\))?\s*$)/') to: '/(?:[\$#>]\s)|(?m:^[\w.-]+\s?[\$#>]?(?:\(config[^\)]*\))?\s?[\$#>]\s?(?:\(enable\))?\s*$)/') I'm sure there is a more elegant way I could have accomplished it, but it works for my limited needs. My problem has now moved to the More prompt. The regex for detecting the More prompt is (?m:^\s*--More--) but the ASA prompts with "<--- More --->" and so far my regex fu has failed. -Chris On Fri, Dec 12, 2008 at 11:35 AM, Chris Knight <bo...@gm...> wrote: > Howdy, > > I know it has been a loooong while since there have been any updates > to this module, but I was wondering if anyone was doing active > development on it, or could give me some pointers in updating the > regex to work with the Cisco ASA. > > I am running a VERY simple script: > > #!/opt/local/bin/perl > > $DEBUG = 1; > > use Net::Telnet::Cisco; > > # my $session = Net::Telnet::Cisco->new(Host => '10.8.0.201'); > # $session->login('admin', 'REDACTED'); > my $session = Net::Telnet::Cisco->new(Host => '10.0.0.1'); > $session->login('proxyit', 'REDACTED'); > $session->enable("REDACTED"); > > # Execute a command > my @output = $session->cmd('show version'); > print @output; > > # Enable mode > if ($session->enable("enable_password") ) { > @output = $session->cmd('show privilege'); > print "My privileges: @output\n"; > } else { > warn "Can't enable: " . $session->errmsg; > } > > $session->close; > exit; > > The error I get when I run it is "pattern match timed-out at > ./CiscoTest.pl line 10", which is the login phase. > > When I packet sniff the telnet session with WireShark, it is clear > that my script is able to log into the ASA, but that the login > function is failing to detect that it received a validly matching > prompt: > > > ............ > > User Access Verification > > Username: .........REDACTED > ...REDACTED > Password: REDACTED > ********** > Type help or '?' for a list of available commands. > > .hq> > > I am unfamiliar with the style of regex being used in the Cisco.pm, > but it would appear to me that this component of the regex _should_ > match the final prompt above: ?[\$#>]\s? > > I am open to any suggestions, including a RTFM if you can point me to > a FM that addresses this style of RegEx. > > Thank you, > > -Chris > |
From: Garry T. W. <gtw...@gm...> - 2008-12-12 21:54:34
|
On Friday 12 December 2008 14:35:48 Chris Knight wrote: [snip] > .hq> You probably want something like this to match that prompt: /^\.[^>]+>/ In other words, match the beginning of a line, a '.', one or more characters that are not '>', and finally '>'. (You might add \s*$ to the end just to make sure.) As I recall, this module lets you set the regular expression for the host's prompt. -- Garry T. Williams --- +1 678 656-4579 |
From: Chris K. <bo...@gm...> - 2008-12-12 19:36:02
|
Howdy, I know it has been a loooong while since there have been any updates to this module, but I was wondering if anyone was doing active development on it, or could give me some pointers in updating the regex to work with the Cisco ASA. I am running a VERY simple script: #!/opt/local/bin/perl $DEBUG = 1; use Net::Telnet::Cisco; # my $session = Net::Telnet::Cisco->new(Host => '10.8.0.201'); # $session->login('admin', 'REDACTED'); my $session = Net::Telnet::Cisco->new(Host => '10.0.0.1'); $session->login('proxyit', 'REDACTED'); $session->enable("REDACTED"); # Execute a command my @output = $session->cmd('show version'); print @output; # Enable mode if ($session->enable("enable_password") ) { @output = $session->cmd('show privilege'); print "My privileges: @output\n"; } else { warn "Can't enable: " . $session->errmsg; } $session->close; exit; The error I get when I run it is "pattern match timed-out at ./CiscoTest.pl line 10", which is the login phase. When I packet sniff the telnet session with WireShark, it is clear that my script is able to log into the ASA, but that the login function is failing to detect that it received a validly matching prompt: ............ User Access Verification Username: .........REDACTED ...REDACTED Password: REDACTED ********** Type help or '?' for a list of available commands. .hq> I am unfamiliar with the style of regex being used in the Cisco.pm, but it would appear to me that this component of the regex _should_ match the final prompt above: ?[\$#>]\s? I am open to any suggestions, including a RTFM if you can point me to a FM that addresses this style of RegEx. Thank you, -Chris |
From: Ejaz <me...@cy...> - 2008-05-27 15:36:56
|
But I have enable 5 password also, it should be like this is it, if (! $enableyes) { $session->cmd(String => "enable 5", Password => 'xxxx', Prompt => '/ERX02>$/', Timeout => '60'); } ----- Original Message ----- From: Burns, Kevin To: Ejaz ; net...@li... Sent: Tuesday, May 27, 2008 6:06 PM Subject: RE: [Net::Telnet::Cisco users] Fw: Juniper Login You have the if statement incorrect. CORRECT: if (! $enableyes) { $session->cmd(String => "enable 5", Prompt => '/ERX02>$/', Timeout => '60'); } ------------------------------------------------------------------------------------------------------------------------ INCORRECT if (! $enableyes) { $session->cmd(String => "enable 5", Password => 'xxxx', Prompt => '/ERX02>$/', Timeout => '60'); } ------------------------------------------------------------------------------ From: Ejaz [mailto:me...@cy...] Sent: Tuesday, May 27, 2008 4:12 AM To: Burns, Kevin; net...@li... Subject: Re: [Net::Telnet::Cisco users] Fw: Juniper Login Dear kevin, Here is the message up on running following script, Please help me [root@reports1 Radiator-3.9]# ./juni.pl ------------------------------------------------------------------ Name "main::enableyes" used only once: possible typo at ./juni.pl line 15. Logging into router 212.119.67.11 bad named parameter "Password" given to Net::Telnet::Cisco::cmd() at ./juni.pl line 17 #!/usr/bin/perl use Net::Telnet::Cisco; #$rtrip = '2xxxxx'; #Password=xxx; sub juniperlogin { $rtrip = $_[0]; print "Logging into router $rtrip\n"; $session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30'); $session->login(Name => 'login', Password => 'xxx', Prompt => '/ERX02>$/', Timeout => '30'); if (! $enableyes) { $session->cmd(String => "enable 5", Password => 'xxxx',Prompt => '/ERX02>$/', Timeout => '60'); } #$session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); } sub junipercmd { $cmd = $_[0]; @output = $session->cmd(String => "$cmd", Prompt => '/ERX02>$/', Timeout => '60'); return @output; } &juniperlogin("1.1.1.1"); @output =&junipercmd("show users"); print @output; ~ ~ "juni.pl" 31L, 925C written ---- Original Message ----- From: "Burns, Kevin" <Kev...@Ca...> To: "Ejaz" <me...@cy...>; <net...@li...> Sent: Tuesday, May 27, 2008 5:37 AM Subject: RE: [Net::Telnet::Cisco users] Fw: Juniper Login Add this code after the session login. if (! $enableyes) { $session->cmd(String => "enable 5", Prompt => '/ERX02>$/', Timeout => '60'); } -----Original Message----- From: net...@li... on behalf of Ejaz Sent: Mon 5/26/2008 3:09 AM To: net...@li... Subject: [Net::Telnet::Cisco users] Fw: Juniper Login Hi, The below script works fine for me but with normal login, Actually i need to go with "enable 5" and with password "xxxx" to get the user details. Here is my prompt for enable, Pleaes have look on it, thanks in advance ERX02>enable 5 Password: ********** ERX02# #!/usr/bin/perl use Net::Telnet::Cisco; #$rtrip = 'xx.xx.xx.xxx'; #$pass='support123'; sub juniperlogin { $rtrip = $_[0]; print "Logging into router $rtrip\n"; $session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30'); $session->login(Name => 'login', Password => 'support123', Prompt => '/ERX02>$/', Timeout => '30'); #$session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); } sub junipercmd { $cmd = $_[0]; #@output = $session->cmd(String => "$cmd", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '60'); @output = $session->cmd(String => "$cmd", Prompt => '/ERX02>$/', Timeout => '60'); return @output; } &juniperlogin("1.1.7.1"); @output =&junipercmd("show version"); print @output; Regards Ejaz ----- Original Message ----- From: Burns, Kevin To: Ejaz Sent: Wednesday, May 21, 2008 8:08 PM Subject: RE: Juniper Login This line is wrong. $session->login(Name => 'login', $pass => 'sut123', Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); Should be: $session->login(Name => 'login', Password => 'sut123', Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); ------------------------------------------------------------------------------ From: Ejaz [mailto:me...@cy...] Sent: Wednesday, May 21, 2008 10:56 AM To: Burns, Kevin Subject: Re: Juniper Login Thanks for your quick response, Up on running here is the error message, am sure my passoword, due to the security reason am not providing proper username and IP of my router. root@reports1 Radiator-3.9]# perl juni.pl Name "main::pass" used only once: possible typo at juni.pl line 15. Logging into router 212.119.67.11 Use of uninitialized value in list assignment at /usr/lib/perl5/site_perl/5.8.0/Net/Telnet/Cisco.pm line 365. usage: $obj->login([Name => $name,] [Password => $password,] [Passcode => $passcode,] [Prompt => $matchop,] [Timeout => $secs,]) at juni.pl line 15 Here is the script #!/usr/bin/perl use Net::Telnet::Cisco; $rtrip = '212.11.7.11'; #$pass='supp23'; sub juniperlogin { $rtrip = $_[0]; print "Logging into router $rtrip\n"; $session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30'); $session->login(Name => 'login', $pass => 'sut123', Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); $session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '60'); } sub junipercmd { $cmd = $_[0]; @output = $session->cmd(String => "$cmd", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout =>'30'); return @output; } &juniperlogin("212.119.1.11"); @output = &junipercmd("show version"); print @output; ~ ----- Original Message ----- From: Burns, Kevin To: Ejaz Sent: Wednesday, May 21, 2008 7:43 PM Subject: RE: Juniper Login You have no password specified. $pass =>, ---------------------------------------------------------------------------- From: Ejaz [mailto:me...@cy...] Sent: Wednesday, May 21, 2008 10:36 AM To: Burns, Kevin Subject: Re: Juniper Login Hi, Here is my script and am sure my password is correct, so please could you tell me where i went wrong, thanks for your support. #!/usr/bin/perl use Net::Telnet::Cisco; $pass='su23'; $rtrip = '212.1.7.1'; sub juniperlogin { $rtrip = $_[0]; print "Logging into router $rtrip\n"; $session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30'); $session->login(Name => 'login', $pass =>, Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); $session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); } sub junipercmd { $cmd = $_[0]; @output = $session->cmd(String => "$cmd", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout =>'30'); return @output; } &juniperlogin("212.11.7.11"); @output = &junipercmd("show version"); print @output; [root@reports1 Radiator-3.9]# ./juni.pl Logging into router 212.119.67.11 Odd number of elements in hash assignment at /usr/lib/perl5/site_perl/5.8.0/Net/Telnet/Cisco.pm line 365. usage: $obj->login([Name => $name,] [Password => $password,] [Passcode => $passcode,] [Prompt => $matchop,] [Timeout => $secs,]) at ./juni.pl line 13 Here is my juniper prompt Here is my juniper prompt. root@reports1 Radiator-3.9]# telnet 212.119.67.1 Trying 212.119.6.11... Connected to 212.119.67.xx(212.119.67.xx). Escape character is '^]'. Telnet password ----------------------------------------------------------------------------------------- Ejaz ----- Original Message ----- From: Burns, Kevin To: me...@cy... Sent: Wednesday, May 21, 2008 7:01 PM Subject: Juniper Login This is how I'm logging into a Juniper. It assumes you will drop into enable. sub juniperlogin { $rtrip = $_[0]; print "Logging into router $rtrip\n"; $session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30'); $session->login(Name => 'XXXXXX', Password => 'XXXX', Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout=> '30'); $session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => ' 30'); } sub junipercmd { $cmd = $_[0]; @output = $session->cmd(String => "$cmd", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); return @output; } &juniperlogin("1.1.1.1"); @output = &junipercmd("show configuration"); print @output; |
From: Burns, K. <Kev...@Ca...> - 2008-05-27 15:07:04
|
You have the if statement incorrect. CORRECT: if (! $enableyes) { $session->cmd(String => "enable 5", Prompt => '/ERX02>$/', Timeout => '60'); } ------------------------------------------------------------------------ ------------------------------------------------ INCORRECT if (! $enableyes) { $session->cmd(String => "enable 5", Password => 'xxxx', Prompt => '/ERX02>$/', Timeout => '60'); } ________________________________ From: Ejaz [mailto:me...@cy...] Sent: Tuesday, May 27, 2008 4:12 AM To: Burns, Kevin; net...@li... Subject: Re: [Net::Telnet::Cisco users] Fw: Juniper Login Dear kevin, Here is the message up on running following script, Please help me [root@reports1 Radiator-3.9]# ./juni.pl ------------------------------------------------------------------ Name "main::enableyes" used only once: possible typo at ./juni.pl line 15. Logging into router 212.119.67.11 bad named parameter "Password" given to Net::Telnet::Cisco::cmd() at ./juni.pl line 17 #!/usr/bin/perl use Net::Telnet::Cisco; #$rtrip = '2xxxxx'; #Password=xxx; sub juniperlogin { $rtrip = $_[0]; print "Logging into router $rtrip\n"; $session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30'); $session->login(Name => 'login', Password => 'xxx', Prompt => '/ERX02>$/', Timeout => '30'); if (! $enableyes) { $session->cmd(String => "enable 5", Password => 'xxxx',Prompt => '/ERX02>$/', Timeout => '60'); } #$session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); } sub junipercmd { $cmd = $_[0]; @output = $session->cmd(String => "$cmd", Prompt => '/ERX02>$/', Timeout => '60'); return @output; } &juniperlogin("1.1.1.1"); @output =&junipercmd("show users"); print @output; ~ ~ "juni.pl" 31L, 925C written ---- Original Message ----- From: "Burns, Kevin" <Kev...@Ca... <mailto:Kev...@Ca...> > To: "Ejaz" <me...@cy... <mailto:me...@cy...> >; <net...@li... <mailto:net...@li...> > Sent: Tuesday, May 27, 2008 5:37 AM Subject: RE: [Net::Telnet::Cisco users] Fw: Juniper Login Add this code after the session login. if (! $enableyes) { $session->cmd(String => "enable 5", Prompt => '/ERX02>$/', Timeout => '60'); } -----Original Message----- From: net...@li... <mailto:net...@li...> on behalf of Ejaz Sent: Mon 5/26/2008 3:09 AM To: net...@li... <mailto:net...@li...> Subject: [Net::Telnet::Cisco users] Fw: Juniper Login Hi, The below script works fine for me but with normal login, Actually i need to go with "enable 5" and with password "xxxx" to get the user details. Here is my prompt for enable, Pleaes have look on it, thanks in advance ERX02>enable 5 Password: ********** ERX02# #!/usr/bin/perl use Net::Telnet::Cisco; #$rtrip = 'xx.xx.xx.xxx'; #$pass='support123'; sub juniperlogin { $rtrip = $_[0]; print "Logging into router $rtrip\n"; $session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30'); $session->login(Name => 'login', Password => 'support123', Prompt => '/ERX02>$/', Timeout => '30'); #$session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); } sub junipercmd { $cmd = $_[0]; #@output <mailto:#@output> = $session->cmd(String => "$cmd", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '60'); @output = $session->cmd(String => "$cmd", Prompt => '/ERX02>$/', Timeout => '60'); return @output; } &juniperlogin("1.1.7.1"); @output =&junipercmd("show version"); print @output; Regards Ejaz ----- Original Message ----- From: Burns, Kevin To: Ejaz Sent: Wednesday, May 21, 2008 8:08 PM Subject: RE: Juniper Login This line is wrong. $session->login(Name => 'login', $pass => 'sut123', Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); Should be: $session->login(Name => 'login', Password => 'sut123', Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); ------------------------------------------------------------------------ ------ From: Ejaz [mailto:me...@cy...] Sent: Wednesday, May 21, 2008 10:56 AM To: Burns, Kevin Subject: Re: Juniper Login Thanks for your quick response, Up on running here is the error message, am sure my passoword, due to the security reason am not providing proper username and IP of my router. root@reports1 <mailto:root@reports1> Radiator-3.9]# perl juni.pl Name "main::pass" used only once: possible typo at juni.pl line 15. Logging into router 212.119.67.11 Use of uninitialized value in list assignment at /usr/lib/perl5/site_perl/5.8.0/Net/Telnet/Cisco.pm line 365. usage: $obj->login([Name => $name,] [Password => $password,] [Passcode => $passcode,] [Prompt => $matchop,] [Timeout => $secs,]) at juni.pl line 15 Here is the script #!/usr/bin/perl use Net::Telnet::Cisco; $rtrip = '212.11.7.11'; #$pass='supp23'; sub juniperlogin { $rtrip = $_[0]; print "Logging into router $rtrip\n"; $session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30'); $session->login(Name => 'login', $pass => 'sut123', Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); $session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '60'); } sub junipercmd { $cmd = $_[0]; @output = $session->cmd(String => "$cmd", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout =>'30'); return @output; } &juniperlogin("212.119.1.11"); @output = &junipercmd("show version"); print @output; ~ ----- Original Message ----- From: Burns, Kevin To: Ejaz Sent: Wednesday, May 21, 2008 7:43 PM Subject: RE: Juniper Login You have no password specified. $pass =>, ------------------------------------------------------------------------ ---- From: Ejaz [mailto:me...@cy...] Sent: Wednesday, May 21, 2008 10:36 AM To: Burns, Kevin Subject: Re: Juniper Login Hi, Here is my script and am sure my password is correct, so please could you tell me where i went wrong, thanks for your support. #!/usr/bin/perl use Net::Telnet::Cisco; $pass='su23'; $rtrip = '212.1.7.1'; sub juniperlogin { $rtrip = $_[0]; print "Logging into router $rtrip\n"; $session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30'); $session->login(Name => 'login', $pass =>, Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); $session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); } sub junipercmd { $cmd = $_[0]; @output = $session->cmd(String => "$cmd", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout =>'30'); return @output; } &juniperlogin("212.11.7.11"); @output = &junipercmd("show version"); print @output; [root@reports1 Radiator-3.9]# ./juni.pl Logging into router 212.119.67.11 Odd number of elements in hash assignment at /usr/lib/perl5/site_perl/5.8.0/Net/Telnet/Cisco.pm line 365. usage: $obj->login([Name => $name,] [Password => $password,] [Passcode => $passcode,] [Prompt => $matchop,] [Timeout => $secs,]) at ./juni.pl line 13 Here is my juniper prompt Here is my juniper prompt. root@reports1 <mailto:root@reports1> Radiator-3.9]# telnet 212.119.67.1 Trying 212.119.6.11... Connected to 212.119.67.xx(212.119.67.xx). Escape character is '^]'. Telnet password ------------------------------------------------------------------------ ----------------- Ejaz ----- Original Message ----- From: Burns, Kevin To: me...@cy... <mailto:me...@cy...> Sent: Wednesday, May 21, 2008 7:01 PM Subject: Juniper Login This is how I'm logging into a Juniper. It assumes you will drop into enable. sub juniperlogin { $rtrip = $_[0]; print "Logging into router $rtrip\n"; $session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30'); $session->login(Name => 'XXXXXX', Password => 'XXXX', Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout=> '30'); $session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => ' 30'); } sub junipercmd { $cmd = $_[0]; @output = $session->cmd(String => "$cmd", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); return @output; } &juniperlogin("1.1.1.1"); @output = &junipercmd("show configuration"); print @output; |
From: Ejaz <me...@cy...> - 2008-05-27 10:17:04
|
Dear kevin, Here is the message up on running following script, Please help me [root@reports1 Radiator-3.9]# ./juni.pl ------------------------------------------------------------------ Name "main::enableyes" used only once: possible typo at ./juni.pl line 15. Logging into router 212.119.67.11 bad named parameter "Password" given to Net::Telnet::Cisco::cmd() at ./juni.pl line 17 #!/usr/bin/perl use Net::Telnet::Cisco; #$rtrip = '2xxxxx'; #Password=xxx; sub juniperlogin { $rtrip = $_[0]; print "Logging into router $rtrip\n"; $session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30'); $session->login(Name => 'login', Password => 'xxx', Prompt => '/ERX02>$/', Timeout => '30'); if (! $enableyes) { $session->cmd(String => "enable 5", Password => 'xxxx',Prompt => '/ERX02>$/', Timeout => '60'); } #$session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); } sub junipercmd { $cmd = $_[0]; @output = $session->cmd(String => "$cmd", Prompt => '/ERX02>$/', Timeout => '60'); return @output; } &juniperlogin("1.1.1.1"); @output =&junipercmd("show users"); print @output; ~ ~ "juni.pl" 31L, 925C written ---- Original Message ----- From: "Burns, Kevin" <Kev...@Ca...> To: "Ejaz" <me...@cy...>; <net...@li...> Sent: Tuesday, May 27, 2008 5:37 AM Subject: RE: [Net::Telnet::Cisco users] Fw: Juniper Login Add this code after the session login. if (! $enableyes) { $session->cmd(String => "enable 5", Prompt => '/ERX02>$/', Timeout => '60'); } -----Original Message----- From: net...@li... on behalf of Ejaz Sent: Mon 5/26/2008 3:09 AM To: net...@li... Subject: [Net::Telnet::Cisco users] Fw: Juniper Login Hi, The below script works fine for me but with normal login, Actually i need to go with "enable 5" and with password "xxxx" to get the user details. Here is my prompt for enable, Pleaes have look on it, thanks in advance ERX02>enable 5 Password: ********** ERX02# #!/usr/bin/perl use Net::Telnet::Cisco; #$rtrip = 'xx.xx.xx.xxx'; #$pass='support123'; sub juniperlogin { $rtrip = $_[0]; print "Logging into router $rtrip\n"; $session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30'); $session->login(Name => 'login', Password => 'support123', Prompt => '/ERX02>$/', Timeout => '30'); #$session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); } sub junipercmd { $cmd = $_[0]; #@output = $session->cmd(String => "$cmd", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '60'); @output = $session->cmd(String => "$cmd", Prompt => '/ERX02>$/', Timeout => '60'); return @output; } &juniperlogin("1.1.7.1"); @output =&junipercmd("show version"); print @output; Regards Ejaz ----- Original Message ----- From: Burns, Kevin To: Ejaz Sent: Wednesday, May 21, 2008 8:08 PM Subject: RE: Juniper Login This line is wrong. $session->login(Name => 'login', $pass => 'sut123', Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); Should be: $session->login(Name => 'login', Password => 'sut123', Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); ------------------------------------------------------------------------------ From: Ejaz [mailto:me...@cy...] Sent: Wednesday, May 21, 2008 10:56 AM To: Burns, Kevin Subject: Re: Juniper Login Thanks for your quick response, Up on running here is the error message, am sure my passoword, due to the security reason am not providing proper username and IP of my router. root@reports1 Radiator-3.9]# perl juni.pl Name "main::pass" used only once: possible typo at juni.pl line 15. Logging into router 212.119.67.11 Use of uninitialized value in list assignment at /usr/lib/perl5/site_perl/5.8.0/Net/Telnet/Cisco.pm line 365. usage: $obj->login([Name => $name,] [Password => $password,] [Passcode => $passcode,] [Prompt => $matchop,] [Timeout => $secs,]) at juni.pl line 15 Here is the script #!/usr/bin/perl use Net::Telnet::Cisco; $rtrip = '212.11.7.11'; #$pass='supp23'; sub juniperlogin { $rtrip = $_[0]; print "Logging into router $rtrip\n"; $session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30'); $session->login(Name => 'login', $pass => 'sut123', Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); $session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '60'); } sub junipercmd { $cmd = $_[0]; @output = $session->cmd(String => "$cmd", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout =>'30'); return @output; } &juniperlogin("212.119.1.11"); @output = &junipercmd("show version"); print @output; ~ ----- Original Message ----- From: Burns, Kevin To: Ejaz Sent: Wednesday, May 21, 2008 7:43 PM Subject: RE: Juniper Login You have no password specified. $pass =>, ---------------------------------------------------------------------------- From: Ejaz [mailto:me...@cy...] Sent: Wednesday, May 21, 2008 10:36 AM To: Burns, Kevin Subject: Re: Juniper Login Hi, Here is my script and am sure my password is correct, so please could you tell me where i went wrong, thanks for your support. #!/usr/bin/perl use Net::Telnet::Cisco; $pass='su23'; $rtrip = '212.1.7.1'; sub juniperlogin { $rtrip = $_[0]; print "Logging into router $rtrip\n"; $session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30'); $session->login(Name => 'login', $pass =>, Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); $session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); } sub junipercmd { $cmd = $_[0]; @output = $session->cmd(String => "$cmd", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout =>'30'); return @output; } &juniperlogin("212.11.7.11"); @output = &junipercmd("show version"); print @output; [root@reports1 Radiator-3.9]# ./juni.pl Logging into router 212.119.67.11 Odd number of elements in hash assignment at /usr/lib/perl5/site_perl/5.8.0/Net/Telnet/Cisco.pm line 365. usage: $obj->login([Name => $name,] [Password => $password,] [Passcode => $passcode,] [Prompt => $matchop,] [Timeout => $secs,]) at ./juni.pl line 13 Here is my juniper prompt Here is my juniper prompt. root@reports1 Radiator-3.9]# telnet 212.119.67.1 Trying 212.119.6.11... Connected to 212.119.67.xx(212.119.67.xx). Escape character is '^]'. Telnet password ----------------------------------------------------------------------------------------- Ejaz ----- Original Message ----- From: Burns, Kevin To: me...@cy... Sent: Wednesday, May 21, 2008 7:01 PM Subject: Juniper Login This is how I'm logging into a Juniper. It assumes you will drop into enable. sub juniperlogin { $rtrip = $_[0]; print "Logging into router $rtrip\n"; $session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30'); $session->login(Name => 'XXXXXX', Password => 'XXXX', Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout=> '30'); $session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => ' 30'); } sub junipercmd { $cmd = $_[0]; @output = $session->cmd(String => "$cmd", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); return @output; } &juniperlogin("1.1.1.1"); @output = &junipercmd("show configuration"); print @output; |
From: Burns, K. <Kev...@Ca...> - 2008-05-27 02:39:43
|
Add this code after the session login. if (! $enableyes) { $session->cmd(String => "enable 5", Prompt => '/ERX02>$/', Timeout => '60'); } -----Original Message----- From: net...@li... on behalf of Ejaz Sent: Mon 5/26/2008 3:09 AM To: net...@li... Subject: [Net::Telnet::Cisco users] Fw: Juniper Login Hi, The below script works fine for me but with normal login, Actually i need to go with "enable 5" and with password "xxxx" to get the user details. Here is my prompt for enable, Pleaes have look on it, thanks in advance ERX02>enable 5 Password: ********** ERX02# #!/usr/bin/perl use Net::Telnet::Cisco; #$rtrip = 'xx.xx.xx.xxx'; #$pass='support123'; sub juniperlogin { $rtrip = $_[0]; print "Logging into router $rtrip\n"; $session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30'); $session->login(Name => 'login', Password => 'support123', Prompt => '/ERX02>$/', Timeout => '30'); #$session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); } sub junipercmd { $cmd = $_[0]; #@output = $session->cmd(String => "$cmd", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '60'); @output = $session->cmd(String => "$cmd", Prompt => '/ERX02>$/', Timeout => '60'); return @output; } &juniperlogin("1.1.7.1"); @output =&junipercmd("show version"); print @output; Regards Ejaz ----- Original Message ----- From: Burns, Kevin To: Ejaz Sent: Wednesday, May 21, 2008 8:08 PM Subject: RE: Juniper Login This line is wrong. $session->login(Name => 'login', $pass => 'sut123', Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); Should be: $session->login(Name => 'login', Password => 'sut123', Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); ------------------------------------------------------------------------------ From: Ejaz [mailto:me...@cy...] Sent: Wednesday, May 21, 2008 10:56 AM To: Burns, Kevin Subject: Re: Juniper Login Thanks for your quick response, Up on running here is the error message, am sure my passoword, due to the security reason am not providing proper username and IP of my router. root@reports1 Radiator-3.9]# perl juni.pl Name "main::pass" used only once: possible typo at juni.pl line 15. Logging into router 212.119.67.11 Use of uninitialized value in list assignment at /usr/lib/perl5/site_perl/5.8.0/Net/Telnet/Cisco.pm line 365. usage: $obj->login([Name => $name,] [Password => $password,] [Passcode => $passcode,] [Prompt => $matchop,] [Timeout => $secs,]) at juni.pl line 15 Here is the script #!/usr/bin/perl use Net::Telnet::Cisco; $rtrip = '212.11.7.11'; #$pass='supp23'; sub juniperlogin { $rtrip = $_[0]; print "Logging into router $rtrip\n"; $session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30'); $session->login(Name => 'login', $pass => 'sut123', Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); $session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '60'); } sub junipercmd { $cmd = $_[0]; @output = $session->cmd(String => "$cmd", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout =>'30'); return @output; } &juniperlogin("212.119.1.11"); @output = &junipercmd("show version"); print @output; ~ ----- Original Message ----- From: Burns, Kevin To: Ejaz Sent: Wednesday, May 21, 2008 7:43 PM Subject: RE: Juniper Login You have no password specified. $pass =>, ---------------------------------------------------------------------------- From: Ejaz [mailto:me...@cy...] Sent: Wednesday, May 21, 2008 10:36 AM To: Burns, Kevin Subject: Re: Juniper Login Hi, Here is my script and am sure my password is correct, so please could you tell me where i went wrong, thanks for your support. #!/usr/bin/perl use Net::Telnet::Cisco; $pass='su23'; $rtrip = '212.1.7.1'; sub juniperlogin { $rtrip = $_[0]; print "Logging into router $rtrip\n"; $session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30'); $session->login(Name => 'login', $pass =>, Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); $session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); } sub junipercmd { $cmd = $_[0]; @output = $session->cmd(String => "$cmd", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout =>'30'); return @output; } &juniperlogin("212.11.7.11"); @output = &junipercmd("show version"); print @output; [root@reports1 Radiator-3.9]# ./juni.pl Logging into router 212.119.67.11 Odd number of elements in hash assignment at /usr/lib/perl5/site_perl/5.8.0/Net/Telnet/Cisco.pm line 365. usage: $obj->login([Name => $name,] [Password => $password,] [Passcode => $passcode,] [Prompt => $matchop,] [Timeout => $secs,]) at ./juni.pl line 13 Here is my juniper prompt Here is my juniper prompt. root@reports1 Radiator-3.9]# telnet 212.119.67.1 Trying 212.119.6.11... Connected to 212.119.67.xx(212.119.67.xx). Escape character is '^]'. Telnet password ----------------------------------------------------------------------------------------- Ejaz ----- Original Message ----- From: Burns, Kevin To: me...@cy... Sent: Wednesday, May 21, 2008 7:01 PM Subject: Juniper Login This is how I'm logging into a Juniper. It assumes you will drop into enable. sub juniperlogin { $rtrip = $_[0]; print "Logging into router $rtrip\n"; $session = Net::Telnet::Cisco->new(Host => $rtrip, Timeout => '30'); $session->login(Name => 'XXXXXX', Password => 'XXXX', Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout=> '30'); $session->cmd(String => "set cli screen-length 0", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => ' 30'); } sub junipercmd { $cmd = $_[0]; @output = $session->cmd(String => "$cmd", Prompt => '/(?m:^\w+@[\w.-]+[>])/', Timeout => '30'); return @output; } &juniperlogin("1.1.1.1"); @output = &junipercmd("show configuration"); print @output; |