I want to run a shell script (POSIX) like this.
# this is a.sh
echo your age?
echo "You are $age."
cat a.sh | /bin/sh -s
The problem is that
/bin/sh is reading the script, and your script is reading input, from the same input file: the pipe fed by
One solution is to modify your script to read directly from the terminal, not standard input, although that may not be exactly what you want.
echo "your age?" read age < /dev/tty echo "Your age $age"
The better solution is to not read the script from standard input; just pass it as an argument to