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.
$ ./your_bash_script1.sh
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
#!/bin/bash
#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" | ./your_bash_script1.sh
echo "N" | ./your_bash_script2.sh
This will take 'Y' as the user input for 'your_bash_script1.sh' and N for your_bash_script2.sh
if your_bash_script1.sh
ReplyDeleterequires more input to send. how will it be done?
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.
ReplyDelete