Script to trigger on address put in certain address list

Hi,

Just getting into doing scripting. I have to Firewall rule that detects someone spamming, and puts them into an address list call spammers. I want to get an email when there is an address-list. I also have some other address lists, also, so trying to count number of entries in address-list doesn’t work. So I will start a script with the scheduler once every 15 mins. So I know how to send emails with a script, but don’t know how to detect if an address has been put into the address-list named spammer. Any ideas.

Thanks
Glenn

/ip firewall address-list> :put [:len [find list=“bogons”] ]

that finally works again in 3.20. Counting entries by list name was broken for quite a few versions (almost a year I think).

Thanks ChangeIP,

I think I can make that work

Glenn

I’d like to be able to receive an email when that happens as well.
I’m just not getting the scripting (too much rf in my head)
Trying to set it up as such:
check for spammer entry count
if count is greater than 0, send email.

/ip firewall address-list
:global spamlist
:set spamlist [:len [find list=“spammer”]]
:if ($spamlist > 0) do= (/tool e-mail send from=me@mydomain.com to=me@mydomain.com server=xxx.xxx.xxx.xxx subject=[/system identity get name] body=“spammer detected”)

No email generated.
I can generate an email with just
/tool e-mail send from=me@mydomain.com to=me@mydomain.com server=xxx.xxx.xxx.xxx subject=[/system identity get name] body=“spammer detected”

The problem is with the > command. I tried with = and <

:put $spamlist
1

Try using { } instead of ( ). do={ };

Thanks.
It’ the little things that make a difference.

One final tweak I’d like.
In the subject I’d like the output to be “system name spammer detected”.

subject={[/system identity get name] “spammer detected”}

I’ve tried this a dozen differnet ways and I get either system name or spammer detected but not together
thanks.

subject=([/system identity get name] . “spammer detected”)

:slight_smile: The parenthesis and curly braces are used in different cases. There are some good samples of scripts in the wiki and the manual, maybe a good time to browse a few of them for syntax.

thanks changeip

I’ve learned what I know from the manual and mostly the wiki.
I have the scripting manual printed but the wiki examples makes them more clear.

missed “.” concatenates two strings

Hello,
looks fine, but how do I get the spammers on the spamlist ?
in my version 2.9.1.8 in the firewall does not work the forward rule to a spamlist, when connection limit is larger then 1 (1 is working, 2 no more)

Thanks Prague