First script need a little guidance

Hello All!

First post so go easy on me :slight_smile:

I have been using my RB2011UiAS for several months and read a lot of manuals and wiki pages for my 'tik and love it. I am now starting to play around with scripts and need a little help/guidance with understanding the syntax that’s probably pretty simple for most.

I am basically trying to use an alternative to netwatch ping failover. The ‘if ping’ commands work stand alone in terminal but when I combine it into the following script the script doesn’t make it to the end. I do not get the email and the log entry “finish” doesn’t appear. I have read most of the scripting/functions wiki pages but I don’t believe I have it structured right, as I said it’s probably something I’ve over looked a few times and would appreciate some input.

#Set needed variables
:local var

#used for testing purposes to test logic below
:set var false

#used for debugging
:log info ("variable is = $var");

:if ($var = false) do={ 
     :log info "Start"
	 :if ([/ping 192.168.1.1 count=5] = 0) do={
                 /tool e-mail send to="xxx@xxx.com" subject="xxx" body="xxxx"}
     :log info "finish"
} else={:log info "else executed"}

Have you tested the “/tool email” line in the terminal? Make sure you’ve configured correct server info in Tools > Email. Other than that, the script worked fine for me.