Community discussions

MikroTik App
just joined
Topic Author
Posts: 1
Joined: Wed Jul 10, 2024 12:13 pm

Script is not working after update

Wed Jul 10, 2024 12:17 pm

Hi, after update to version 7 my script stopped working, can u help me what shoud i change ?
:local array1 [:toarray " 02:C5:E1:7D:A1:09,DC:F0:50:E2:84:F7,1E:3D:59:2E:38:13,E2:B5:FA:8B:6F:B2"]
:local array2 [ :toarray "" ];

:local SendTo ""
:local SendFrom "";
:local PasswordMail "2374u5i6rew#^$&*";
:local SmtpServer [:resolve ""];
:local UserName "";
:local SmtpPort 465;
:local UseTLS "tls-only";
:local Subject "WARNING: Unauthorised host connected";

:foreach mac in=[/ip arp print as-value where interface="bridge3"] do={:set array2 ( $array2, $mac->"mac-address")}
:foreach mac in=$array2 do={:if ([:find $array1 $mac] >= 0) do={} else={/tool e-mail send to=$SendTo server=$SmtpServer port=$SmtpPort start-tls=$UseTLS user=$SendFrom password=$PasswordMail from=$SendFrom subject=$Subject body="Unauthorised host was connected: $mac"}}
Member Candidate
Member Candidate
Posts: 154
Joined: Mon Nov 07, 2016 3:23 am

Re: Script is not working after update

Sun Jul 14, 2024 5:04 pm

Try to look at the script like that: ... 174d07a0c5

It's much prettier then what you supplied.
Also test if it works.
If it doesn't work you should add some:
    :do { 
        :log info "works";
    } on-error={ 
        :log error ("$[:jobname] : error happened");
Use the divide and conquer tactic.
Try to run the script adding some parts of the code at a time to see what is failing.
Maybe there was a change you are not aware of in the commands you already use.

And also you don't need the:
:local SmtpServer [:resolve ""];
you should just use:
:local SmtpServer "";

Who is online

Users browsing this forum: No registered users and 41 guests