Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Net:Telnet to Nortel Switch

by dperdomo (Initiate)
on Aug 20, 2007 at 21:28 UTC ( #633945=perlquestion: print w/replies, xml ) Need Help??
dperdomo has asked for the wisdom of the Perl Monks concerning the following question:

I try to do a connection via Net:Telnet to Switch Nortel Networks BayStack 420, but i have a problem, to begin i have to press CTRL-Y, i donīt know how sent that, if connect first display in mode Menu, next i have to press "c" to enter Command Line, and here i got to execute various commands. Somebody help me, please. I use Net:Telnet:Cisco in a Switch Cisco and work excellent, but this Nortel i canīt. Thanks.

Replies are listed 'Best First'.
Re: Net:Telnet to Nortel Switch
by calin (Deacon) on Aug 20, 2007 at 21:58 UTC
    to begin i have to press CTRL-Y, i donīt know how sent that

    See this Wikipedia page.

    sub ctrl { return chr( ord( uc(shift) ) - 64 ); }
      This is the .pl that i use, where i put this sub??
      use Net::Telnet (); $t = new Net::Telnet (Timeout => 5, output_log => "c:\DP\Perl\output.log", Host => ""); #$t->open(""); #$t->login($username, $passwd); @v1 = $t->cmd("\cY"); print @v1; @v2 = $t->cmd("c"); print @v2; #$t->print("\cY"); #$t->print("c"); @v1 = $t->cmd("sh ip"); print @v1; @v1 = $t->cmd("exit"); print @v1; print "l"; $t->close; exit;
      I donīt understand the reference?? This script will leave unattended, i not sure that "sub ctrl" do that i want, or maybe i donīt give a good explain . I try to create a script in Perl to do a Telnet to Switch, i describe the step: after i type telnet, the switch show me a message: "Press Ctrl-Y to begin", after show a menu, donīt ask me for user or password because i disable that. In the menu i have to press "C" to enter "Command Line Mode" and then write all commands to configurate the switch; next i have to type exit and will back to menu, next press "l" to logout of telnet. OK? All this i try to do a script unattended. Itīs possible? Well,i probe the "sub ctrl" but if any other sugestion will welcome, Thanks a lot. (sorry for my english)

        The ctrl example sub is equivalent to the \c built-in construct that you are using. I was under the impression that you didn't understand how control characters are generated from their respective symbol.

        As for why your script doesn't work please be more specific. What doesn't work? Have you checked return values and error status after each step? Try to read the Net::Telnet documentation from beginning to end. I'm not familiar with the module but after a brief read I can suggest some starting points for investigation.

        Quoting from the docs:

        • The default Prompt is '/[\$%#>] $/'
        • The methods login() and cmd() use the prompt setting in the object to determine when a login or remote command is complete. Those methods will fail with a time-out if you don't set the prompt correctly.
        • Use a combination of print() and waitfor() as an alternative to login() or cmd() when they don't do what you want.

        The login possibly times out because "Press Ctrl-Y to begin" doesn't match the default prompt. Also the login will probably stall if you disable password authentication on the switch. Use the docs!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://633945]
Approved by Corion
[erix]: nobody knows what kind it takes :)
[erix]: I say his seems a face that launches a thousand missiles :)
[Your Mother]: I say I do. :P
[Your Mother]: Missiles would be an idiot’s play. Putin is many things but he is not an idiot.
[erix]: I like the idea of the trumps troup of imbeciles growing slightly nervous now their incompetence will be tested
[erix]: you seem forget there is another idiot coming :)
[Your Mother]: The US government does not attract talent, but grafters and liars and it has been that way for the better part of a century. FEW exceptions.
[erix]: you think it only /looks/ worse this time?
[Your Mother]: HR Clinton was literally threatening Russia. She would have been MUCH more likely to start real trouble.
[Your Mother]: I think there is less decorum this time.

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2017-01-20 00:59 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (173 votes). Check out past polls.