BGP Peer state

Hi All,

I have a problem with a script; it works good via shell but doesn’t work on system/script also if I import the code exactly as is.


{:if ([/routing bgp peer get [find name="CYMRU-1"] state] = "established") do={:global CYMRUSTATE;:delay 1;:set $CYMRUSTATE value="1";} else={:log error message="BGP Peer state not established"; /routing ospf instance set 0 distribute-default=never; :if ($CYMRUSTATE = "1") do={/tool e-mail send from=r1@mydomain.it server=X.X.X.X to=support@mydomain.it subject="BGP Peer down" port=25 body="BGP Peer down";:delay 1;:set $CYMRUSTATE value="0";}}}

When the peer is enstablished, it set the $CYMRUSTATE=1 (works); when the peer is idle it writes in log, it change OSPF instance but doen’t change $CYRMUSTATE to 0 and doesn’t send mail; same script copied and pasted in terminal works without problems,

WHY ? Any ideas ?

Nobody ?

you should start your script the following way:

{:global CYMRUSTATE; if … }

you always need to declare that a variable is global in the script, even if it exists. otherwise you can’t reference it.

your code defined CYMRUSTATE in an IF condition. so whenever the condition was fulfilled, you had the variable in your scope, otherwise you don’t have access to it.
if you run the same script as CLI, you already have CYMRUSTATE in your scope.

Hi doneware,

OK, now it works good.

Thank you so much !!