3-> This is easy:
for i in $(<logfile);do echo $i;done
1-> This is a little harder:
Code:
#!/bin/bash
echo "Start..."
sleep 20 &
PROCESS=$!
count=0
while [ $PROCESS = "`pidof sleep`" ]
do
echo "Still running"
sleep 1
((count++))
echo $count
if [ $count = 19 ]
then
kill -9 "$PROCESS"
break
fi
done
echo "Done..."
The above example is using sleep but you just replace that with tnsping. The $! means the last process put in background. Try it and change the numbers and you'll see what it is doing.
2-> I'm not sure I understand this question. You want to run tnsping more than once in background?
<command1> & #command1 running in background
PROCESS1=$! #$PROCESS1 is the pid of command1
<command2> & #command2 running in background
PROCESS2=$! #$PROCESS2 is the pid of command2
wait #Don't do any more processing until all background processes complete.