Net::SSH - how to respond to a prompt before first command?

S

Slawek Zachcial

Hello,

I'm trying to connect, using SSH, to a server that immediately after
login executes a script that requires input from user. The script is
asking the user to select the target username that the shell should
switch to. I'm using WinXP to run the script, the target server is
running HP-UX and the user is switched using 'pbrun' command.

Here is the code I used to connect and then execute the "date" command:

Net::SSH.start(myhost, myuser, :password => mypassword, :keys => mykeys,
:passphrase => mypassphrase, :verbose => :debug) do |ssh|
puts ' ######', ' #', ' # ' + ssh.exec!("date"), ' #', ' ######'
end

When I run this script connecting to another host which does not require
the user input immediately after login everything works fine. That's why
I suspect that the user input part is causing the problem.

I attached the logs generated by the script for the "Working Scenario"
and "Not Working Scenario".

When I execute the script connecting to the server where it does not
work, the script basically hangs.

I tried all kind of things with channels, I also looked through this
forum and generally on the web. No luck. I admit that I'm a Ruby newbie
so I may be missing something obvious here.

Any help would be greatly appreciated.

Thanks,
/Slawek

Attachments:
http://www.ruby-forum.com/attachment/2356/ssh.rb.log
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,742
Latest member
AshliMayer

Latest Threads

Top