Closed abadfish closed 7 years ago
Does the 'Please press return to continue' happen before or after the '@apl.cmd("\n")' line?
It happens before.. I have also tried:
@apl.waitfor(/Please press return to continue/) do |apl|
apl.cmd( " ", /WHICH OPTION/)
apl.cmd("EXP", /WHICH FUNCTION/)
end
Gotcha. The problem you're hitting is that Net::SSH::Telnet::new has a waitfor embedded in it with the default prompt. You'll need to do something like:
@apl = Net::SSH::Telnet.new(
...
'Prompt' => /Please press return to continue/,
)
@apl.prompt = /[$%#>] \z/n # This is the default prompt used by Net::SSH::Telnet
@apl.cmd(<your first command>)
To do this, you'll need to switch from the net-ssh-telnet gem to the net-ssh-telnet2 gem, and install at least version 0.2.0
Please let me know if this works for you.
Ok. I uninstalled net-ssh-telnet and installed net-ssh-telnet2. When requiring the gem in the file do I still require 'net/ssh/telnet' ?
That's right, its still a require of 'net/ssh/telnet' and is a drop in replacement for net-ssh-telnet.
I double checked my existing code, the snippet above should be something closer to:
@apl = Net::SSH::Telnet.new(
...,
'Prompt' => /Please press return to continue/,
)
@apl.prompt = /[$%#>] \z/n # This is the default prompt used by Net::SSH::Telnet
@apl.cmd('')
@apl.cmd(<your first command>)
@apl.cmd(<your first command>)
This is what I have now and it's still timing out:
@apl= Net::SSH::Telnet::new(
"Session" => ssh,
"Dump_log" => @dumpf,
"Output_log" => @logf,
"Timeout" => 20,
"Prompt" => /Please press return to continue/
)
@apl.prompt = /[$%#>] \z/n
@apl.cmd(" ")
@apl.cmd("EXP")
Would you mind sending me a copy of your log file (with any sensitive data removed)? Here or email works.
Last unsuccessful login: Mon Apr 17 10:48:48 2017 on ssh from XXX.XXX.XXX.XXX Last login: Tue Apr 18 13:04:14 2017 on ftp from ::ffff:XXX.XXX.XXX.XXX**
Dyalog APL/S-64 Version 12.1.0 Classic For IBM RISC System/6000 Created: May 29 2015 at 10:54:54 Copyright (c) Dyalog Limited 1982-2015 (B[?7l[?1l(B[0m(B[0m[H[2J[0mDyalog APL/S-64 Version 12.1.0[2;1HClassic Edition[3;1HTue Apr 18 13:04:19 2017[24;62H[0m [4;1H[0m/sa/Prgs/PA12 saved Fri Dec 4 20:40:11 2009[24;62H[0m PA12 M0 Ins[4;45H(B[5;1H[0mPORTVUE - 04/18/17 1:04 P.M.(WA=450617296 )[5;1H(B[6;1HSETACCT[5;1H(B[7;1H****Sensitive information removed....(0lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq[24;80H(B [22;1H(0x(B System Tip for the day-[24;80H [22;1H(0x[24;80H(B ... [22;1H(0x[24;80H(B [22;1H(0mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq(B[24;80H [22;1H[24;68H[0mPA12 M0 Ins(B[23;1H[K[24;1H[K[24;80H [22;1H[0mGO(B[24;80H [22;1HNo outstanding news available(B[23;1HPlease press return to continue[24;68H[0mPA12 M0 Ins(B[24;68H PV[23;33H
And the end of the dump log:
1b 5b 32 34 3b 38 30 48 0d 0a 1b 5b 32 32 3b B.[24;80H...[22;
< 0x001f0: 31 48 1b 5b 32 34 3b 36 38 48 1b 5b 30 6d 50 41 1H.[24;68H.[0mPA
< 0x00200: 31 32 20 4d 30 20 20 49 6e 73 12 M0 Ins
< 0x00000: 1b 28 42 1b 5b 32 33 3b 31 48 1b 5b 4b 1b 5b 32 .(B.[23;1H.[K.[2
< 0x00010: 34 3b 31 48 1b 5b 4b 1b 5b 32 34 3b 38 30 48 0d 4;1H.[K.[24;80H.
< 0x00020: 0a 1b 5b 32 32 3b 31 48 1b 5b 30 6d 47 4f ..[22;1H.[0mGO
< 0x00000: 1b 28 42 1b 5b 32 34 3b 38 30 48 0d 0a 1b 5b 32 .(B.[24;80H...[2
< 0x00010: 32 3b 31 48 4e 6f 20 6f 75 74 73 74 61 6e 64 69 2;1HNo outstandi
< 0x00020: 6e 67 20 6e 65 77 73 20 61 76 61 69 6c 61 62 6c ng news availabl
< 0x00030: 65 1b 28 42 1b 5b 32 33 3b 31 48 50 6c 65 61 73 e.(B.[23;1HPleas
< 0x00040: 65 20 70 72 65 73 73 20 72 65 74 75 72 6e 20 74 e press return t
< 0x00050: 6f 20 63 6f 6e 74 69 6e 75 65 1b 5b 32 34 3b 36 o continue.[24;6
< 0x00060: 38 48 1b 5b 30 6d 50 41 31 32 20 4d 30 20 20 49 8H.[0mPA12 M0 I
< 0x00070: 6e 73 1b 28 42 1b 5b 32 34 3b 36 38 48 20 20 50 ns.(B.[24;68H P
< 0x00080: 56 1b 5b 32 33 3b 33 33 48
Closing this - for anyone finding this later, the fix involved setting the 'Terminator' option to "\r" when initializing Net::SSH::Telnet as that's what AIX was wanting instead of "\n"
I posted this first in the original net-ssh-telnet repo and the owner referred me to this one. Hoping someone has some insight.
My logfile says I get to a place where the shell says "Please press return to continue" after logging in. I've tried using #waitfor(/Please press return to continue/) and #cmd(" ") or #cmd("\n") and it still hangs. Anyone have any idea how to better send the command?