Interactive programs in shell scripts

If a program reads from its standard input, we can use the “here document” concept in shell scripts. It is best illustrated with an example. Suppose we have a program p1 that reads two integers followed by a string. We can orchestrate this in our script as follows:

#!/bin/s”

p1 <<END
12 22
string1
END

where END is an arbitrary token denoting the end of the input stream to the program p1.