Community discussions

MUM Europe 2020
 
arielgrin
just joined
Topic Author
Posts: 12
Joined: Fri Jun 07, 2013 3:40 pm

Script runs from terminal but doesn't run from scheduler

Fri Jun 07, 2013 3:52 pm

I have a RB751G-2HnD running RouterOS 5.25
I have found that the following script will run OK when launched from the console, but not from webfig, winvox or scheduler:

:global IPSECOLD
:local IPSECNEW [:resolve xyz.dyndns.org]
:if ($IPSECNEW != $IPSECOLD) do={
:set IPSECOLD $IPSECNEW
/ip ipsec policy set 1 sa-dst-address=$IPSECNEW
/ip ipsec peer set 1 address="$IPSECNEW/32"
:log info "IPSec: remote peer updated"
} else={
:log info "IPSec: no update needed"
}

The specific command that won't execute when script is run from either, webfig, winbox or scheduler is:
/ip ipsec peer set 1 address="$IPSECNEW/32"

If the condition is met, the log only shows "ipsec policy changed by admin" and nothing else when run from webfig, winbox or scheduler, while if run from terminal, all the actions are executed and get logged: "ipsec policy changed by admin", "ipsec peer changed by admin", "IPSec: remote peer updated"

Could this be a bug on 5.25? I'm pretty sure that this was working correctly on 5.23
 
aoakeley
newbie
Posts: 38
Joined: Mon May 21, 2012 11:45 am

Re: Script runs from terminal but doesn't run from scheduler

Tue Nov 12, 2013 11:19 am

Did you ever figure this out.
Different script but same symptoms.
Runs fine if I execute it from terminal, but not from Winbox or Netawatch

this is all that is in the script
/ip route set [find comment=WAN1] distance=10
/ip route set [find comment=WAN2] distance=20

ROS 6.6 - but tried some older versions with same result
 
User avatar
tomaskir
Trainer
Trainer
Posts: 1122
Joined: Sat Sep 24, 2011 2:32 pm
Location: Slovakia

Re: Script runs from terminal but doesn't run from scheduler

Tue Nov 12, 2013 5:47 pm

Try:
/ip route set [/ip route find comment=WAN1] distance=10
/ip route set [/ip route find comment=WAN2] distance=20
Unimus - configuration management, automation and backup solution
Mass Config Push, network-wide RouterOS upgrades, and more!
 
Ivoshiee
Member
Member
Posts: 471
Joined: Sat May 06, 2006 4:11 pm

Re: Script runs from terminal but doesn't run from scheduler

Tue Nov 12, 2013 7:51 pm

There are different set of variable scopes for each mode of script startup. Until it is not fixed or improved, it is better to reduce any use of global variables. The ROS scripting is a terrible beast - simple script will beg the CPU too much for my likings. I hope for a JIT compiler to get implemented.

Who is online

Users browsing this forum: No registered users and 18 guests