Reputation: 787
I run a bash script. After some minutes execution it prompts me enter 'Y' or 'N' to continue. Some minutes later it can prompt me again some times.
Is it possible to answer its questions automatically in common if I know the count and sequence of right answers (e.g. Y, N, N, N)
Upvotes: 1
Views: 4832
Reputation: 1296
The Expect tool used in cases like this. It is useful for automating interaction with CLI applications (Expect on Wikipedia).
Upvotes: 1
Reputation: 16379
Try a here document:
bashscript.shl [options] <<-END
Y
Y
Y
N
END
Put any kind of answer you want, passwords, etc. Will NOT work for ssh or sftp.
Upvotes: 3