Operating System - HP-UX
1836872 Members
2385 Online
110110 Solutions
New Discussion

Re: need script to provide program user repsonse

 
Rick Burge_3
Occasional Advisor

need script to provide program user repsonse

I have this program which needs to be called repeatedly with different arguments. The program itself eventually asks the user to answer yes or no to a question.

I have written a script which repeatedly calls the program with different arguements, no problem. But it is possible for me to know the answer to the yes or no question ahead of time. So I'd like the script to provide the user's repsonse automatically. Basically if I know the answer will always be yes each time the program is called, when the program has stopped and is waiting on the user input I want the script to respond with yes.

Any examples?

Thanks,
Rick
2 REPLIES 2
Patrick Wallek
Honored Contributor

Re: need script to provide program user repsonse

I would look at using Expect for something like this.

Expect allows you to respond depending on the prompt that is presented.

http://hpux.connect.org.uk/hppd/hpux/Tcl/expect-5.43/
Amit Agarwal_1
Trusted Contributor

Re: need script to provide program user repsonse

Well 'expect' is one tool that you can use. But since there is only one point of user interaction you can use pipe (|)

$ echo yes | <script>

You can even capture the results if you want.

$ x=`echo yes | <script> `
$ echo $x