Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-10-14
2
Medium Priority
?
1,114 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 500 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Six Sigma Control Plans

715 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