Net/ssh/telnet waifor method

I’m attempting to write a ruby script that logs into a box and runs
commands/scripts remotely.

This is what I’ve got below:

ssh = Net::SSH.start(“server1”, “admin”, :password => “Password”) do
|ssh|
s = Net::SSH::Telnet.new(“Session” => ssh)

puts s.cmd(“cd /tmp”)
puts s.cmd(“ls -la”)
puts s.waitfor()( This is my hang-up right now)
puts s.close
end

I want the waitfor method to “wait” for the $ or # on the command line
or the prompt to indicate that the previous command has finished and to
move on to the next, whether it be to close or to run another command.

Thanks!

Have you tried reading the documentation?

I haven’t used it myself, but to match a line with only a dollar or
hash, I would expect it to be something like:
s.waitfor /^($|#)$/