From: ZipiZap zap Date: 2012-06-30T09:10:12+09:00 Subject: Re: Ruby pty and expect --20cf3074b46628154604c3a56381 Content-Type: text/plain; charset=ISO-8859-1 Also if any time later you need more from ruby+ssh, have a look at gem net-ssh https://github.com/net-ssh/net-ssh Cheers On 29 June 2012 21:10, Tim L. wrote: > That was it. thanks a million > > PTY.spawn("ssh -o StrictHostKeyChecking=no user@#{address}") do |reader, > writer, pid| > reader.expect(/Password/) > writer.puts("my_password") > reader.expect(/\$|Password/) do |a, b| > if a.match(/\$/) > writer.puts("ifconfig") > reader.expect(/\$/) > writer.puts("exit") > reader.expect(/\$/) > else > Process.kill(9, pid) > end > > > end > > -- > Posted via http://www.ruby-forum.com/. > > --20cf3074b46628154604c3a56381 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Also if any time later you need more from ruby+ssh, have a look at gem net-= ssh

https= ://github.com/net-ssh/net-ssh

Cheers

On 29 June 2012 21:10, Tim L. <lists@ruby-forum.com> wrot= e:
That was it. =A0thanks a million

PTY.spawn("ssh -o StrictHostKeyChecking=3Dno user@#{address}") do= |reader,
writer, pid|
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reader.expect(/Password/)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0writer.puts("my_password") =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reader.expect(/\$|Password/) do |a, b|<= br> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if a.match(/\$/)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0writer.puts("ifconfig"= ;)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reader.expect(/\$/)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0writer.puts("exit") =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reader.expect(/\$/)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0else
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Process.kill(9, pid)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0end


=A0 =A0 =A0 =A0 =A0 =A0end


--20cf3074b46628154604c3a56381--