Hello There,

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

In reply to Noway to login correctly into Nortel Switch by coldroom

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.