I’m using batch commands to send a script to all my routers via SSH (with Plink and PSCP). Plink executes a script inside script.something file.
I noticed that /system backup save name=$filename; and /export file=$rsc; overwrite the files already existing and create updated files every time I run the batch file (perfect!).
Now, I need to append to this script some other funcionalities like enable logging, change default IP services, create administrators users and remove default admin user, set ntp client, etc.
The question is:
How do I can check if the configuration already exists in the Mikrotik and skip to the next command? (to avoid duplicating lines, like it happens when I run the logging script)
For example - check with if there exists user with name “adm”
:if ([:len [user find name~“adm”]]>0) do={:put “exists”}
Or for those setting where you are not allowed to add same records - catch run-time errors
:do {user add group=full name=admin} on-error={:put “can’t add user admin”}