Hi Rendezz,
Uh.... it seems I know far less about RouterOS Scripting than I thought (which wasn't much)..... What do you mean by compile? I didn't see anything about compiling in the wiki/manual. Compiling might mean IDE or text editor (I found that there is notepad++ with syntax highlighting.... is there something better?
I also found
was helpful.
What you posted worked great and it helped my learn a bit more about scripting. Thank you!
So I then decided to tweak it a little more and broke it again.
I wanted to get the list of IPs from the address list, put them in a variable (vCurrentRDPIPs) and include them in the email, but now when I run /system scripts print it highlights "get" on line 7 in red. I assume this is bad and I need to fix it. I tried print as well as a few other things but couldn't get it to work. Do I need an Array for multiple lines?
Thanks for all of your help.
I found the scripting wiki/manual and the tips and tricks. Are there any other good ways to learn scripting?
#Define variables
global vCurrentStatus;
global vCurrentRDPIPs;
global vNewStatus;
#find number of connected RDP Users
:set vNewStatus [:len [/ip firewall address-list find list="RDPUserConnected"]];
:if ($vNewStatus != $vCurrentStatus) do={
#If change in RDP user count - send email
:if ($vNewStatus != 0) do={
#Get list of RDP IPs
:set $vCurrentRDPIPs [:get [/ip firewall address-list find list="RDPUserConnected"]];
/tool e-mail send to=user@domain.com subject="RDP Users" body="The following $vNewStatus RDP IPs are currently connected \r test $vCurrentRDPIPs" start-tls=yes;
} else={
/tool e-mail send to=user@domain.com subject="RDP Users" body="There are no longer any RDP IPs connected" start-tls=yes;
}
:set vCurrentStatus $vNewStatus;
}