Sunday, July 31, 2011

Send automatic predefined input variable parameters to a script called by another script in bash through command line prompt

If you want to run a bash script inside a bash script to automate it, but the inside bash script asks and waits for a keyboard input variable from the user to proceed, this tip will become handy.

$ ./
Welcome to the XYZ script
Would you like to rewrite the output files? Please input Y for yes or N for no
Now script waits for Y or N input from user. i.e you have to input Y or N to proceed. So if you want to put these script inside another bash script, you would have to enter is as many times and it asks. How to automate a predefined input, say Y, to it and sit lazy while the script does everything by itself and finishes off?. Try echo piping

#Send automatic predefined input variable parameter to a script called by another script
#in bash through command line prompt in Linux.linux bash through command prompt
echo "Y" | ./
echo "N" | ./

This will take 'Y' as the user input for '' and N for


  1. if
    requires more input to send. how will it be done?

  2. Even i need answer for this, in middle of executing a script in another script, i need to pass some input. Please let me know how can we do that.