Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Control:CLI or Net::SSH2 - Send <ctrl>_

by Mr. Muskrat (Canon)
on Feb 20, 2017 at 23:07 UTC ( [id://1182379]=note: print w/replies, xml ) Need Help??


in reply to Control:CLI or Net::SSH2 - Send <ctrl>_

Without an SSCCE of the problem you are having, all we can do is guess but I'd rather not do that.

  • Comment on Re: Control:CLI or Net::SSH2 - Send <ctrl>_

Replies are listed 'Best First'.
Re^2: Control:CLI or Net::SSH2 - Send <ctrl>_
by ImJustAFriend (Scribe) on Feb 21, 2017 at 02:11 UTC
    I created a test script with the relevant code for this. The latest iteration of that code is seen below, with IP addresses/usernames/passwords changed for public sharing...

    #!C:/Perl64/bin/perl.exe use Control::CLI; my $mrvip = "1.2.6.4"; my $mrvuser = "mrvuser"; my $mrvpass = "mrvpass"; my $mrvport = "5"; my $mrvenpass = "mrvenpass"; my $oauser = "oauser"; my $oapass = "oapass"; my $bladeuser = "bladeuser"; my $bladepass = "bladepass"; my $obj; my $ok; my $output; my @blades = qw/1 2 3 4 5 6/; my @switches = qw/1 2/; $obj = new Control::CLI ( Use => 'SSH', Timeout => 10800, Input_log => "mrv_oa.input.log", Output_log => "mrv_oa.output.log", Dump_log => "mrv_oa.dump.log", ); $ok = $obj->connect( Host => $mrvip, Username => $mrvuser, Password => + $mrvpass,); $ok = $obj->login( Password => $mrvpass,); $output = $obj->cmd(""); my $oaconn = $obj->cmd("conn port asy $mrvport\n"); if ( $oaconn =~ m/.*Unable to connect to port.*/s ) { $output = $obj->cmd("en"); $output = $obj->cmd("$mrvenpass"); $output = $obj->cmd("logout port asy $mrvport"); $oaconn = $obj->cmd("conn port asy $mrvport"); } $output = $obj->cmd(""); my $oaloginu = $obj->cmd("$oauser"); my $oaloginp = $obj->cmd("$oapass"); foreach my $blade (<@blades>) { print "Connecting To Blade $blade...\n"; my $bladeconn = $obj->cmd("connect server serial $blade\n"); if ($bladeconn =~ m/service is unavailable/s ) { next; } my $port = $obj->port; if (defined($port)) { print " Connected To Blade $blade!\n"; my $bladexit1 = $obj->cmd("\033\050"); } else { print " Not Connected To Blade $blade...\n"; } } foreach my $switch (<@switches>) { print "Connecting To Switch $switch...\n"; my $bladeconn = $obj->cmd("connect interconnect $switch\n"); my $port = $obj->port; if (defined($port)) { print " Connected To Switch $switch!\n"; my $switchexit = $obj->print("\037"); # <== PROBLEM $output = $obj->put("D"); # <== PROBLEM } else { print " Not Connected To Switch $switch...\n"; } } #$output = $obj->cmd("quit"); #$output = $obj->print("\032"); #$output = $obj->print("\145"); #$output = $obj->cmd("e");

    The worst part is, in the dump log, I can see it sending the HEX to the remote machine, but it does not respond properly to the code (in this case, the "1f" 2 lines from bottom)...

    ... redacted for readability... < 0x00020: 0d 0a 45 73 63 61 70 65 20 63 68 61 72 61 63 74 ..Escap +e charact < 0x00000: 65 72 20 69 73 20 27 3c 43 74 72 6c 3e 5f 27 20 er is ' +<Ctrl>_' < 0x00010: 28 43 6f 6e 74 72 6f 6c 20 2b 20 53 68 69 66 74 (Contro +l + Shift < 0x00020: 20 2b 20 55 6e 64 65 72 73 63 6f 72 65 29 0d 0d + Unde +rscore).. < 0x00000: 0a 0d 0a 50 72 65 73 73 20 5b 45 6e 74 65 72 5d ...Pres +s [Enter] < 0x00010: 20 74 6f 20 64 69 73 70 6c 61 79 20 74 68 65 20 to dis +play the < 0x00020: 73 77 69 74 63 68 20 63 6f 6e 73 6f 6c 65 3a 20 switch +console: > 0x00000: 1f 0a .. > 0x00000: 44 D

      At the risk of going out on another limb today might i suggest you try replacing my $switchexit = $obj->print("\037"); # <== PROBLEM with  my $switchexit = $obj->put("\037"); sleep 2;, the sleep 2 serving to present a time break in case the switch implements a "time guard interval" like the old hayes AT command set did.

      > 0x00000: 1f 0a
      That's your escape character followed by a newline!

      So you aren't sending "Escape-D", but "Escape-Newline-D". You should use ->put instead of ->print for this.

      Of course, waiting some seconds, as huck recommends, doesn't hurt, but ->print's trailing output_record_separator would undo the escaping anyway…

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1182379]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (10)
As of 2024-04-18 08:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found