Reputation: 139
I have a shell script as follows
ln -s -f /ctf/message/dave.inbox /home/alice/imoprt.inbox
/ctf/message/sendmsg
echo hello
The purpose of the script is to first make a link, then run a program, and provide hello as input to the program. It all works except providing hello as the input. I can do this easily by writing a script just like
echo hello
but then I am unable to do some other things, such as linking before. Is there a way to do this sequence of commands?
Upvotes: 0
Views: 2156
Reputation: 212248
There are a few common ways to provide input to a command:
echo input | cmd
{ echo one; echo two; echo three; } | cmd
cmd <<EOF
line 1 of input
line 2 of input
EOF
trap 'rm -f fifo' 0
mkfifo fifo
cmd < fifo &
{
echo line 1 of input
var=$( echo line 2 of input generated dynamically )
echo "$var"
echo another line of input
} > fifo
wait
Upvotes: 2