Solved

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

Posted on 2004-10-14
2
1,077 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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now