Community discussions

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

Wilcard in Scripts?

Sun Sep 10, 2023 6:47 pm

Hi,

Is there a wildcard function for Mikrotik scripts? Do you have 2 examples here?
:if ([:find $identity "AP"] != -1) do={
    /system scheduler add interval=1m name=updateSchedule on-event="/system script run updateScript" start-date=sep/02/2023 start-time=00:05:00;
} else={ 
    /system scheduler add interval=2m name=updateSchedule on-event="/system script run updateScript" start-date=sep/02/2023 start-time=00:05:00;
}

or
:global UpdateURL "sftp://mikrotik.com/routeros-*-arm.npk"
 
nescafe2002
Forum Veteran
Forum Veteran
Posts: 900
Joined: Tue Aug 11, 2015 12:46 pm
Location: Netherlands

Re: Wilcard in Scripts?

Sun Sep 10, 2023 7:31 pm

Every 1m?
 
dima1002
Member Candidate
Member Candidate
Topic Author
Posts: 160
Joined: Fri Jan 26, 2018 8:40 pm

Re: Wilcard in Scripts?

Sun Sep 10, 2023 7:33 pm

this was only a test :-)
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12025
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Wilcard in Scripts?

Mon Sep 11, 2023 9:43 am

Is there a wildcard function for Mikrotik scripts?
:global UpdateURL "sftp://mikrotik.com/routeros-*-arm.npk"
NO.
 
nescafe2002
Forum Veteran
Forum Veteran
Posts: 900
Joined: Tue Aug 11, 2015 12:46 pm
Location: Netherlands

Re: Wilcard in Scripts?

Wed Sep 13, 2023 1:03 pm

dima1002, regarding the original question - you cannot use wildcards in the fetch function.

However, it is possible to auto-update your device using the standard update function. It will detect and download the applicable packages within the chosen channel.
/system package update
set channel=stable
check-for-updates
install

The router will contact upgrade.mikrotik.com and check the latest version (https://upgrade.mikrotik.com/routeros/LATEST.7).
If there is a new version available, it will download the correct package(s) and initiate a reboot.
If there is no new version available, nothing happens.

In scheduler, auto update every night at 3am:
/system scheduler
add interval=1d name=auto-update on-event="/system package update\r\
    \nset channel=stable\r\
    \ncheck-for-updates\r\
    \ninstall" policy=read,write,policy start-date=2023-09-13 start-time=03:00:00

I would recommend against following this approach. Better use The Dude to centrally monitor, manage and update your APs and other devices.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12025
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Wilcard in Scripts?

Wed Sep 13, 2023 7:46 pm

I thought the stupidest thing someone could do is automatically update the device as soon as a new version comes out,
but I hadn't considered the act of sharing a script that does it, just usable with copy & paste...
 
nescafe2002
Forum Veteran
Forum Veteran
Posts: 900
Joined: Tue Aug 11, 2015 12:46 pm
Location: Netherlands

Re: Wilcard in Scripts?

Wed Sep 13, 2023 7:59 pm

rextended, thank you for your rude and unhelpful answer.
As explained, I would recommend against this auto update functionality and provided an alternative.

Compared to never updating the device, a scheduled auto update would not be the worst option?

Do you provide alternatives? Could you try to at least provide helpful insights instead of just bashing users?
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12025
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Wilcard in Scripts?

Wed Sep 13, 2023 8:13 pm

Compared to never updating the device, a scheduled auto update would not be the worst option?
What is it? A competition to see who does the worst thing?
It is actually better to have an out of order peripheral than a poorly managed one which will then cause mass attacks on others.
I agree with this.
So from now on I will omit warning about the just-out self-update, so that those who are not able to manage the device correctly will sooner or later stop managing it altogether...

Who is online

Users browsing this forum: Materique and 12 guests