I'm absolutely new to expect command. Suppose that there is a script file named 'a.rb', which is written in ruby:
STDOUT << 'Overwrite /opt/rails/rails_app/Gemfile? (enter "h" for help) [Ynaqdh] '
s = STDIN.gets
STDOUT << s
It works as bellow:
$ruby a.rb
Overwrite /opt/rails/rails_app/Gemfile? (enter "h" for help) [Ynaqdh] #wait user's input
y # show the user's input and exit
It seems good to use expect command if I want to automate the user's input.
So I tried to make a script file (a.expect):
spawn ruby a.rb
expect "Overwrite /opt/rails/rails_app/Gemfile\? \(enter \"h\" for help\) \[Ynaqdh\] "
sleep 3
send "y\r"
But this script doesn't work and I don't know why. That is my question.
$ expect -f a.expect
spawn ruby a.rb
Overwrite /opt/rails/rails_app/Gemfile? (enter "h" for help) [Ynaqdh]
$ # <= expect script has finished because of (maybe) timeout?!