While-Do-If-Then-Else Problem

Hi All,
Sorry I am a beginner in shell scripting and need a help with my script.
logic : I am checking for a process, if thats running then sleep and check again and if not then start another process. I have tried it like this, but getting a lot of error, can anyone help.

#!/bin/sh
while true
        do
            PCOUNT=`ps -ef | grep pspdaq1601b | grep bahs5 | grep -c -v grep`

        If [[$PCOUNT -gt 0 ]]; then
            echo " rating is still running..."

            sleep 10

            # if no rating is running, then stop rating_file_monitor

            else

                 echo " rating is not running, will go ahead and stop rating"

                 /cer_bahsu59/exe/stop_rating_file_monitor.sh

                 echo " starting reject rating run "

                P1=0 P2=NNNN P3=M P4=TI P5= P6= P7= P8= ./pspdaq1601b 

                 echo " All Reject runs finished for the day "

                 /cer_bahsu59/exe/start_rating_file_monitor.sh

         exit 0

            fi

For starters:

  • use if , not 'If'.
  • You need a space after the [[
  • There is no done statement
1 Like

Thank you for your advise, got it working now :slight_smile: