Community discussions

MikroTik App
 
dima1002
Member Candidate
Member Candidate
Topic Author
Posts: 160
Joined: Fri Jan 26, 2018 8:40 pm

Run script and another script

Mon Oct 24, 2022 7:43 pm

Hi,

I want to run 2 scripts in a loop. How can this work?

do={ /system/scheduler/disable test AND /system reboot }"
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11968
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Run script and another script

Mon Oct 24, 2022 8:22 pm

2 scripts or 2 instructions?
in a loop or one after the other?
Is better you change your translator...

You only wrote a fragment,
writing "do={}" is useless at all, unless there is some very specific reason, it is useless.
It's not the first time I've seen scripts that use it unnecessarily.

in same row:
/system scheduler disable test ; /system reboot

in two row
/system scheduler disable test
/system reboot
 
dima1002
Member Candidate
Member Candidate
Topic Author
Posts: 160
Joined: Fri Jan 26, 2018 8:40 pm

Re: Run script and another script

Mon Oct 24, 2022 9:28 pm

Hello Rextended,

1. I want one Script
2. One after the other
3. I would like to query a status, if the status is not the same, a script should be deactivated and then a reboot

For example like this
( [get xxxx] != [get xxxx] ) do={ SCRIPT DISABLE AND system reboot }"
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11968
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Run script and another script

Mon Oct 24, 2022 10:12 pm

is not a "SCRIPT DISABLE" is one instruction...

please provide at the start the details, for example "get what"...

example code

:if ([get xxxx] != [get xxxx]) do={ /system scheduler disable test ; /system reboot }
 
dima1002
Member Candidate
Member Candidate
Topic Author
Posts: 160
Joined: Fri Jan 26, 2018 8:40 pm

Re: Run script and another script

Mon Oct 24, 2022 11:36 pm

OK thanks, the script works perfectly.
But I have a logic error.

I need a scheduler that runs once on startup and then disables itself.
or a scheduler script that is only executed once at boot.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11968
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Run script and another script

Tue Oct 25, 2022 12:27 am

executed once at first boot after the scheduler is set, then disable itself and reboot:
/system scheduler
add name=reboot_script start-time=startup policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
    on-event=":delay 20s; :if (true != false) do={ /system scheduler disable reboot_script; /system reboot }"

self destructing scheduler, after the scheduler is set, once executed at boot, delete itself and reboot
/system scheduler
add name=reboot_script start-time=startup policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
    on-event=":delay 20s; :if (true != false) do={ /system scheduler remove reboot_script; :delay 1s; /system reboot }"

various delays on scripts are needed, are not optionals

replace "true != false" with the condition you need
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11968
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Run script and another script

Tue Oct 25, 2022 12:32 am

something suggests to me that you might need to check if the firmware is updated, and in case restart for apply the new version???
 
dima1002
Member Candidate
Member Candidate
Topic Author
Posts: 160
Joined: Fri Jan 26, 2018 8:40 pm

Re: Run script and another script

Tue Oct 25, 2022 9:34 am

Yes, I had something similar in mind. How do you know?
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11968
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Run script and another script

Tue Oct 25, 2022 11:39 am

after years I have some intuition... :lol:

If you do not want dual reboot, extract the firmware file from the corresponding .npk with 7-zip and update before reboot.

For example, if the device is one CRS112-8P-4S, check what is the right firmware type on system / routerboard, on this case is qca8513L
Open with winzip the file routeros mipsbe .npk, go to etc folder, extract qca8513L_xxx.fwf, place it on root of the routerboard,
and when on system / routerboard appear new version under upgrade firmware, upgrade
on this way is not needed the dual reboot.
(after upgrade you do not see the current firmware change, is the old until reboot)

Obviously if the device is one CPE, this can suffice:
/system scheduler
add name=reboot_script start-time=startup policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
    on-event=":delay 20s; :if ([/sys rou get current-firmware] != [/sys rou get upgrade-firmware]) \
    do={ /system scheduler remove reboot_script; :delay 1s; /system reboot } \
    else={ /system scheduler remove reboot_script }"

Who is online

Users browsing this forum: diamuxin, Ellaham and 23 guests