coldroom has asked for the wisdom of the Perl Monks concerning the following question:
Before, sorry for my english.
Well, what I want : Doing a script which do a config backup of a looong nortel (Baystack) switch's list.
My problem, it seem I can't log on them correctly !
Manually, I have to connect, press Ctrl-Y, enter my login, my password, press Shift+C to enter in the command line and do what i want.
Actually, my script works ONLY if i don't have to login on my switch. When I have to logon, I don't have error message, but the config file server tftp side is emtpy..
Note that I can't use SNMP method or Expect.
Here's the code :
#!/usr/bin/perl use Net::Telnet; $serveur_tftp = 'x.x.x.x'; our $switchlist_nortel_conf = "nortel.txt"; our @devices_nortel; open(FILEHANDLER, "<$switchlist_nortel_conf") or die "ERREUR : $switch +list_nortel_conf n'existe pas !\n"; while (<FILEHANDLER>) { next if (/^\n$/); next if (/^#/); chomp; push (@devices_nortel, $_); } close(FILEHANDLER); foreach $switch_nortel_conf (@devices_nortel) { &Recup_nortel; } sub Recup_nortel { @switch_nortel_details = split(/ /, $switch_nortel_conf); $prompt = qw(/\>/); $out_log='log/Out_Log_'.@switch_nortel_details[1].'.txt'; $in_log='log/In_Log_'.@switch_nortel_details[1].'.txt'; $dump_log='log/Dump_Log_'.@switch_nortel_details[1].'.txt'; $t= new Net::Telnet (Timeout=>55, Errmode=>'return', Dump_log=>$dump_log, Input_log=>$in_log, Output_log=>$out_log, prompt=>$prompt ); $t->open(@switch_nortel_details[0]) or die $t->errmsg;; print ("DEBUG : Connexion effectuée\n"); print ("DEBUG : Envoi de Ctrl-Y \n"); $var_0=chr(25); @ctrly=$t->print($var_0) or die $t->errmsg; print ("DEBUG : Envoi du login => @switch_nortel_details[3]\n"); $t->waitfor('/Username:/i'); $var_1="@switch_nortel_details[3]"; @login=$t->print($var_1) or die $t->errmsg; print ("DEBUG : Envoi du password => @switch_nortel_details[2]\n") +; $t->waitfor('/Password:/i'); $var_2="@switch_nortel_details[2]"; @password=$t->print($var_2) or die $t->errmsg; print ("DEBUG : Selection de la ligne de commande (envoi de Maj+C) + \n"); $var_3=chr(67); @majc=$t->print($var_3) or die $t->errmsg; print ("DEBUG : Envoi de enable\n"); $t->cmd("enable") or die $t->errmsg; print ("DEBUG : Envoi de copy running-config tftp address $serveur +_tftp filename @switch_nortel_details[1]\n"); $t->cmd("copy running-config tftp address $serveur_tftp filename @ +switch_nortel_details[1]"); #or die $t->errmsg; print ("DEBUG : Envoi de close\n"); $t->close or die $t->errmsg; return 1; } exit;
Note : If I #comment all the identification lines, and I try to connect on a unsecured switch, all works fine !
Please help, I am on this problem since a big week :\
Many Thanks
Ju update :the in_log :
Ethernet Switch 470-24T HW:07 FW:3.6.0.7 SW:v3.7.0.04 ISV +N:2 Username: [ ] [ *************** ] Enter Username: julian@tri-srv-jh:~/telnet$ Enter text, press <Return> or <Enter> when complete.
the outlog :
julian@tri-srv-jh:~/telnet$ cat log/Out_Log_470_BS9.txt mylogin mypassword C enable copy running-config tftp address x.x.x.x filename 470_BS9
And the prompt clientside :
DEBUG : Connexion effectuée DEBUG : Envoi de Ctrl-Y DEBUG : Envoi du login => mylogin DEBUG : Envoi du password => mypassword DEBUG : Selection de la ligne de commande (envoi de Maj+C) DEBUG : Envoi de enable DEBUG : Envoi de copy running-config tftp address x.x.x.x filename 470 +_BS9 DEBUG : Envoi de close
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Noway to login correctly into Nortel Switch
by roboticus (Chancellor) on Jan 21, 2010 at 11:24 UTC | |
|
Re: Noway to login correctly into Nortel Switch
by Anonymous Monk on Jan 21, 2010 at 17:28 UTC |