I'm trying to write a script which helps me to search in log for a phrase "started".
The script that I have until now looks like this:
#!/bin/bash
greperg= 
i=3
echo "Web server is going to be polled"
while 
    i=`expr $i - 1`
    #polling
    echo "Polling Nr. $i"
    grep -q '^started$' log
    greperg=$?
 
    #test, if it goes on
    test "$greperg" -gt 0 -a "$i" -gt 0
do
    #waiting    
    echo 'waiting ...'
    sleep 1
done    
if test  "$greperg" -eq 0 
then 
    echo "Web server has started" 
else
    echo -n "Web server is not started"
fi
valid=''
while ((!valid)); do
    echo - "Do you want to poll again? (J/N)"
    read -t 5  answer
    case "$answer"  in 
        [Jj]) result=1; valid=1;;
        [Nn]) result=0; valid=1;;
        "")   result=0; valid=1;;
        *)    valid=0 ;;
    esac 
done
echo
if ((result));then
     : # ...............(repeat the process again, if its not found ask max 5 times)
else
    echo "Timeout"
fi
exit 0
From line 38, I don't know how to re-run it, can anybody help?
What i'm looking for:
- The polling should be expanded: If after the 3 attempts that word (started) is still not there, then ask the user with a (Y / N) query whether more should be polled 3 times or not. 
- The user should be asked a maximum of 5 times (So a maximum of 3 × 6 = 18 times is polled). 
- At the very end please state what the status reached is (see example below). 
 - polling ... Web server has not started yet. Wait ... polling ... Web server has not started yet. Wait ... polling ... Web server has not started yet. Should it be polled again (Y / N)? _ Y polling ... Web server has not started yet. Wait ... polling ... Web server has not started yet. Wait ... polling ... Web server has not started yet. Should it be polled again (Y / N)? _ N As requested, no further attempts are made. Bottom line: web server has not started.
 
     
    