Community discussions

MikroTik App
 
User avatar
SiB
Forum Guru
Forum Guru
Topic Author
Posts: 1888
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Scheduler add on-event={multi-line script} ?  [SOLVED]

Thu Oct 07, 2021 12:21 am

Hello

I new add a scheduler from inside script/netwatch etc. and this create a problem with multi-line.

One line is easy:
/system scheduler add name=Every10s on-event="/log warning \"LTE Down\"; /log warning ThisCanWorkBySemicollon" interval=00:00:30
We can pass variable values but still this not solve multi-line.
local test 5
/system scheduler add name=Every10s on-event=("/log warning \"".$test."\"") interval=00:00:10

Solved by "\r\n"

local line1 "log warning Line1"
local line2 "log warning Line2"
local line3 "log warning Line3"
/system scheduler add name=Every10s on-event=($line1."\r\n".$line2."\r\n".$line3) interval=00:00:10
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12001
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Scheduler add on-event={multi-line script} ?

Thu Oct 07, 2021 1:44 am

{ } just for test on terminal
{
:local test 5
/system scheduler add name=Every10s on-event=":log warning \"$test\"" interval=00:00:10
}


{
:local line1 ":log warning Line1"
:local line2 ":log warning Line2"
:local line3 ":log warning Line3"
/system scheduler add name=Every10s on-event="$line1\r\n$line2\r\n$line3" interval=00:00:10
}

Who is online

Users browsing this forum: saied and 30 guests