Alex Rivera | Logout

Simulating ENTER keypress in bash script

Asked 2011-06-07T11:37:22.550
159

I've created a really simple bash script that runs a few commands. one of these commands needs user input during runtime. i.e it asks the user "do you want to blah blah blah?", I want to simply send an enter keypress to this so that the script will be completely automated.

I won't have to wait for the input or anything during runtime, its enough to just send the keypress and the input buffer will handle the rest.

Edit
Report

1 Answer

11

You could make use of expect (man expect comes with examples).

answered 2011-06-07T11:41:21.103

Your Answer