I agree with the regex comment and also I have had an easier time / better
luck using net-ssh for these type of actions.



On Fri, Jun 29, 2012 at 8:10 PM, ZipiZap zap <zipizap123 / gmail.com> wrote:

> 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> 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/.
>>
>>
>