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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs