Solved

Sending <shift><ctrl><6> key sequence (net::telnet::cisco)

Posted on 2004-10-14
2
1,094 Views
Last Modified: 2008-01-09
I'm using Perl and net::telnet::cisco to run some scripts against a list of Cisco devices.  At one point in the script, I change the IP address of a device and my session hangs up for about 9 minutes until it times out.  I'd like to be able to send a break sequence to the device to kill the session..  Basically, what  I need to do is send the key sequence <shift><ctrl><6> to the device.  Syntax for N::T::C command as follows:

$ntc1->cmd('command');

Any suggestions?  Thanks - Rich
0
Comment
Question by:rcris001
  • 2
2 Comments
 
LVL 13

Expert Comment

by:gripe
ID: 12321944
This is just a shot in the dark, but you could try:

$ntc1->cmd("\c^");

Or possibly (should be the same as above):

$ntc1->cmd(chr(30));

Hope that helps and let me know if it doesn't work, I'm sure we can find a different way.
0
 
LVL 13

Accepted Solution

by:
gripe earned 125 total points
ID: 12322003
Based on the innards of Net::Telnet::Cisco, this is how it's done.

However, Net::Telnet::Cisco has a method available for sending a break which does the same thing behind the scenes:

$ntc_object->ios_break;

From line 196 in perldoc Net::Telnet::Cisco:

       ios_break - send a break (control-^)
               $ok = $obj->ios_break;

           You may have to use errmode(), fork, or threads to break at the an
           appropriate time.

Relevant code block from 'Net::Telnet::Cisco':

sub ios_break {
    my $self = shift;

    my $old_ors = $self->output_record_separator;
    $self->output_record_separator('');
    my $ret = $self->print("\c^");
    $self->output_record_separator($old_ors);

    return $ret;
}

0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question