I have two shell scripts namely test1.sh and test2.sh I have to call test2.sh from test1.sh For test1.sh I need to pass one parameter as a command line argument and for test2.sh I need to pass a parameter at the prompt.

Code sample:

$ cat test2.sh
echo "enter id value"
<br>read id
#do some processing here

How do I call test2.sh from test1.sh?

I can not edit test2.sh file here

2 Answers 2


if test2.sh is in the same directory, it's as simple as

file: test1.sh

echo 5 | ./test2.sh

man read has the opening:

read -- read a line from standard input

perhaps you were just missing the dot slash ./, which is required for finding the script in the current directory. Alternatively, you can have your $PATH variable point to the folder containing test2.sh. Then ./ is not required.


in test1.sh

echo whatever | test2.sh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.