Hi,
The example I gave does what you ask for.
When you start the script (the example given in post #4), stail1.1.pl is started and the output is given, a line at the time, to the while read loop. Inside the while read loop you can do what you want/need with the individual lines.
If you stop the example script (ctrl-c) the stail1.1.pl is also killed.
Here's an example where stail1.1.pl is replaced by a tail -f on a log file. It looks for the word completed and prints the date/time and the process:
Code:
#!/bin/bash
tail -f /var/log/allmessages | \
while read LINE
do
# echo $LINE
awk '/completed/ { print $1, $2, $3, $5 }'
done
Example run:
Code:
first is example output generated by the tail -f process
$ tail -f /var/log/allmessages
Oct 13 15:20:00 exile fcron[21639]: Job /usr/lib/sa/sa1 & started for user admin (pid 21640)
Oct 13 15:20:02 exile fcron[21639]: Job /usr/lib/sa/sa1 & completed
Oct 13 15:25:00 exile fcron[21706]: Job /usr/lib/sa/sa1 & started for user admin (pid 21707)
Oct 13 15:25:02 exile fcron[21706]: Job /usr/lib/sa/sa1 & completed
Oct 13 15:30:00 exile fcron[21820]: Job /usr/lib/sa/sa1 & started for user admin (pid 21821)
Oct 13 15:30:02 exile fcron[21820]: Job /usr/lib/sa/sa1 & completed
Oct 13 15:35:00 exile fcron[21903]: Job /usr/lib/sa/sa1 & started for user admin (pid 21904)
Oct 13 15:35:02 exile fcron[21903]: Job /usr/lib/sa/sa1 & completed
running the script
$ ./tester.sh
Oct 13 15:20:02 fcron[21639]:
Oct 13 15:25:02 fcron[21706]:
Oct 13 15:30:02 fcron[21818]:
Oct 13 15:30:02 fcron[21820]:
Oct 13 15:35:02 fcron[21903]:
Hope this clears things up a bit.