Skip to content

heredoc to feed an interactive program

Let this interactive.sh be the interactive program:

#!/bin/sh
read input1
read input2
echo $input1 $input2

This is a script feed.sh (in the same directoty) that uses heredoc to feed two lines to interactive.sh:

#!/bin/sh
./interactive.sh << EOF
asdf
zxcv
EOF

It work as:

$ ./feed.sh
asdf zxcv
Published inenglish

Be First to Comment

Leave a Reply

Your email address will not be published.