Solved

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

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Syslog text file into database or into .CSV 19 153
Perl script to parse log and delete the file 17 176
Port 80 requests 16 100
Perl File::Find alternative 1 78
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 …
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…

809 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