Problems with my first script

Hi,

I’m trying to figure out where I’m going wrong with a script that I have written. This is my first script, so guess its a syntax error somewhere.

I have a global array called $avocet, which is used with the script below. I aim to have this script run every minute, and the aim is that after 5 minutes of downtime, it should be reported to me via email. I used netwatch, but I was inundated with emails from my router. If anyone can help me with this it would be greatly appreciated, if anyone has an alternative way of doing what I want, pease also let me know

:local p [/ping ($avocet->"ip") count=3];
:if ($p = 0) do={
    :set ($avocet->"counter") (($avocet->"counter") + 1);
    :log info "avocet failed";
    :if (($avocet->"counter") = 5) do={
        /tool email send to=me@myemailaddress.co.uk subject="Avocet Mast DOWN";
    }
} else={
    :if (($avocet->"counter") != 0) do={
        :log info "avocet up";
        /tool e-mail send to=me@myemailaddress.co.uk subject="Avocet Mast UP";
    }
:set ($avocet->"counter") 0;
}

Kind regards
James

Running from terminal gives:
“bad command name email (line 8 column 15)”
i.e. you missed “-” in “e-mail”

Thanks for that, I missed that one.

I still have the same issue, whether the ping replies or fails, it always runs the else clause. From a terminal I ran the variable declaration (using global instead of local), then did an environment print, which gave me the results I was expecting. I then added a :log entry into the if statement to echo the value of p into the log. Again it shows the correct value, so why isnt the if statement working properly?

James

Hmm, I just pasted the script into the terminal and enclosed it with { } and it works. I then ran the script again from script list, and it didnt work. So whats different between running it from terminal and running from script list?

Now I’m confused
James