IF statement doesn't work properly in osascript I'm working on script which should do something if application is running or not Also there should be a timer of checking(60 seconds) The problem is that "if" statement which is checking "count" doesn't work.

Here is a script:

#!/bin/bash
osascript -e "do shell script \"

COUNT="0"

while true;
do
    if (ps aux | grep Skype | grep -v grep &gt; /dev/null)
    then
        echo "RUNNING" &gt; /Users/someuser/Desktop/RUNNING.txt
    else
        echo "STOPPED" &gt; /Users/someuser/Desktop/STOPPED.txt
    fi

    sleep 1
    COUNT=$((COUNT+1))

    if (("$COUNT" &gt; "60"))
    then
        exit 0
    fi

done

\" with administrator privileges"
This way works:

#!/bin/bash
osascript -e do shell script \"

COUNT=0

while true;
do
    if (ps aux | grep Skype | grep -v grep &gt; /dev/null)
    then
        echo 'RUNNING' &gt; /Users/someuser/Desktop/RUNNING.txt
    else
        echo 'STOPPED' &gt; /Users/someuser/Desktop/STOPPED.txt
    fi

    sleep 1
    COUNT=$((COUNT+1))

    if (($COUNT &gt; 60))
    then
        exit 0
    fi

done
\" with administrator privileges



You don't need the quotes before do shell script, as this is an applescript sentence.
Avoid unnecessary double quotes to prevent errors.