Solved

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

Posted on 2004-10-14
2
1,103 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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
Perl 101 11 85
ppm conversion to curl on a module install 8 88
Excel to CSV conversion with specific columns 5 97
Vb script to unzip a files and rename the files 5 103
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…

740 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