next up previous contents
Next: Useful commands for shell Up: Shell programming Previous: Arithmetic in shell scripts   Contents

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/sh

p1 <<END
12 22
string1
END

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



Amit Jain 2013-04-22