Unix run script help.

SuperTool

Lifer
Jan 25, 2000
14,000
2
0
Hi. I am using a program with an annoying user interface. It asks me lotsof stupid questions. And I have to run it a lot to simulate my asynchronous adder. Can I write a script that runs the program and automatically answers question when it sees a prompt? How would I do that? Many thanks everyone.
 

nd

Golden Member
Oct 9, 1999
1,690
0
0
If it uses STDIN for input you can easily simulate input by using pipes to send data to its STDIN (which would normally come from the keyboard).

% echo "thisisstuffthatitype" | some_program

When "some_program" is ran it will receive "thisistuffthatitype" to its STDIN.

You can use printf to use some other special characters:

% printf "yes\nyes\n\nyes\n" | some_program

Will simulate pressing yes<enter> 3 times