From: Brian Candler Date: 2011-10-29T04:26:58+09:00 Subject: Re: How to SSH interactive Session KING SABRI wrote in post #1028587: > However, it doenst solve my issue > > ------------------------------------------------------------ > require 'net/ssh/telnet' > > host = "127.0.0.1" > 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 :( Yes, well you have to explicitly expect the two different outcomes and deal with them. Net::Telnet has built-in expect-like functionality. s.cmd is basically a shortcut for "send this, then expect a prompt". So you need to use s.puts, expect with a regexp which matches either a normal prompt or the password expiry, and if you get a password expiry then deal with it appropriately. -- Posted via http://www.ruby-forum.com/.