How to implement an interactive input with ruby script?

I want to automate their actions to manage the server by writing a
program on Ruby.
How to perform automatic data entry, when the program asks for it? For
example, enter the password.

I want to automate their actions to manage the server by writing a
program on Ruby.
How to perform automatic data entry, when the program asks for it? For
example, enter the password.

expect is often used for this, by continually reading an IO stream until
triggering a particular pattern. You just need to require 'expect' and
then it will become an instance method of IO, and thus be available to
pipes, network sockets, etc.

http://www.ruby-doc.org/stdlib/libdoc/pty/rdoc/IO.html

has the documentation on it.

Regards,
Chris W.

Thank you. this is the right direction:

require ‘pty’
require ‘expect’

PTY.spawn(“command”) do |reader, writer, pid|
result=reader.expect("")
writer.puts “password”
result=reader.expect(“bye”)
p result
end