Community discussions

MikroTik App
 
shtrom
just joined
Topic Author
Posts: 12
Joined: Wed Aug 18, 2021 4:16 pm

Which policy for scheduled script using email?

Sun Jul 17, 2022 8:59 am

Hi all,

I am working on a script that goes through the DHCP leases. When it finds a new lease, it creates a static DNS entry for the machine, and sends an email. The script is originally based on https://www.ctrl.blog/entry/routeros-dh ... cript.html.

The script works (DNS updated, email sent) when I run it manually as the admin, with
> /system script run dhcp-to-dns
I am trying to set up the least amount of privileges on all my scripts. In doing so, I got confused as it seems the (scheduled) script just dies without warning if it doesn't have the permissions. I eventually whittled it down to:
* read, to read DHCP leases and static DNS entries
* write, to update static DNS entries

Those policies are both setup for the script itself, as well as the scheduler entry
> :put [/system script get dhcp-to-dns policy ]
read;write
> :put [/system scheduler get dhcp-to-dns policy ]
read;write
Unfortunately, when run by the scheduler, the script dies (silently) when trying to send the email. I have looked at https://help.mikrotik.com/docs/display/ROS/E-mail, https://help.mikrotik.com/docs/display/ROS/User, https://help.mikrotik.com/docs/display/ ... repository and https://help.mikrotik.com/docs/display/ROS/Scheduler, but haven't been able to find any indication of what policy/permission the email tool needs.

So, two questions:
1. Is there a way to get a better log output when a script dies because it doesn't have permission to run a particular command?
2. What is the policy required for scripts to be able to send emails?

Thanks in advance.
 
shtrom
just joined
Topic Author
Posts: 12
Joined: Wed Aug 18, 2021 4:16 pm

Re: Which policy for scheduled script using email?  [SOLVED]

Wed Oct 18, 2023 5:17 am

I reached out to MT support via https://help.mikrotik.com, and got this reply:
To send an email, you also need a test policy.
It worked!

Who is online

Users browsing this forum: Bing [Bot], FlowerShopGuy, GoogleOther [Bot], mbezuidenhout and 69 guests