From: "Tim L." Date: 2012-06-30T02:06:11+09:00 Subject: Ruby pty and expect I'm trying to write a program that will log into a list of ip's and run a command. I running into an issue with expect. When I get logged in I want to run the command, but some machines the password doesn't work. When this happens it returns the password prompt again, I want to kill the process when this happens and move to the next ip. Her is the code I have but doesn't work correctly. Any help will be appreciated. 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("$") else Process.kill(9, pid) end end end -- Posted via http://www.ruby-forum.com/.