Shortly, using yes
yes is a tool for repeating some string infinitely.
You can pass 1 yes, then 1 no, then again 1 yes and 1 no and so on by using:
yes $'yes\nno' | ./script.sh
Using bash, you could reverse the pipe by using process-substitution syntax:
./script < <(yes $'yes\nno')
Sample:
head -n 6 < <(yes $'yes\nno')
yes no yes no yes no
... or two yes and one no:
head -n 6 < <(yes $'yes\nyes\nno')
yes yes no yes yes no
Or any other combination...
Further
As your question stand for:
If the bash script has multiple input (more than one) how can I pass it ?
Little sample (using a function instead of a script, for demo):
myScript() { while read -rp 'Name: ' name && [[ -n $name ]]; do read -rp 'Last name: ' lName || break read -rp 'Birth date (YYYY-MM-DD): ' birth || break bepoch=$(date -d "$birth" +%s) printf 'Hello %s %s, you are %d years old.\n' \ "$name" "$lName" $(((EPOCHSECONDS-bepoch)/31557600)) done }
Sample run:
myScript
Name: John Last name: Doe Birth date (YYYY-MM-DD): 1941-05-03 Hello John Doe, you are 83 years old.
Using inline string
myScript <<<$'John\nDoe\n1941-05-03'
Hello John Doe, you are 83 years old.
Using inline text
myScript <<eoInput John Doe 1941-05-03 James Bond 1953-04-13 eoInput
Hello John Doe, you are 83 years old. Hello James Bond, you are 72 years old.