variable equals variable

Hi.

I am trying to run a script that checks if a pptp-client is connected, if not then send an email. I don’t want it to send a mail every time the script runs so I am trying to do the foloowing

:global oldb1 “$b1”;
:global b1 [:len [/ppp active find where name=“b1”]];

if ( ($b1 = 0) && ($oldb1 != 0) ) do={:put “b1 offline” }


This works fine when I run it in the terminal but when I run the script I get

syntax error (line 1 column 22)

Whats the correct the syntax for making 1 variable equals another

It doesn't work because you are trying to access variable which is not yet defined.
:global oldb1;
:global b1 ;

:if ([/ppp active find where name="b1"] != "") do={
:set b1 true;
} else={
:set b1 false;
}

:if ( ($b1 != $oldb1) do={
:set oldb1 $b1

send email

}

Thanks a lot. makes sense

btw, now mail will be sent when interface changes state, that is it becomes disconnected or becomes connected again. you have to check if state change is from true to false and then send the e-mail.