From: Robert Klemme Date: 2011-10-27T00:21:46+09:00 Subject: Re: How to SSH interactive Session On Wed, Oct 26, 2011 at 2:35 PM, KING SABRI wrote: > Thanks Brian,, > "Net::SSH::Telnet" is has an advantage which it's keeping the session > open until finish all commands not like "Net::SSH" which is create a > session for each command/communication. > > However, it doenst solve my issue > > ------------------------------------------------------------ > require 'net/ssh/telnet' > >  host = "127.0.0.1" >  port = 15000    # SSH port >  user = 'userName'  # username >  pass = "password"  # password > > > s = Net::SSH::Telnet.new("Host" => host, "Username" => user, "Password" > => pass) > >  puts s.cmd("pwd") >  puts s.cmd "sudo passwd userName" > ------------------------------------------------------------ > > that's my code :( Not sure whether that works but you could use "expect" to match and react on what the remote side says. require 'expect' # example with file File.open "x" do |io| io.expect /^prompt/ do |line| puts "Got #{line}" io.puts "exit" end end Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/