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