Community discussions

MikroTik App
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

Help cant create ip address list

Tue Apr 25, 2023 5:34 pm

Please do help, id like to create a script wherein when the sys scheduler is disabled, automatically it will create ip address list base on ppp active name and ip, here's my code
/system scheduler
:foreach item in=[find where disabled] do={
    :local disAcc [get $item name]
    /ppp active
    :foreach sname in=[find where name=$disAcc] do={
        :local ip [get $sname address]
        :local notif [get $sname name]
        :log warning "Acc Name: $notif IP: $ip"
        /ip firewall address add list=PPPOE-CLIENT-NOTIFY address=$ip comment=$notif
    }
}
Thankyou in advance
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Help cant create ip address list

Tue Apr 25, 2023 8:38 pm

The description is bad, especially is not clear the final goal.

If you have a scheduler for each user, and you want to put in one address-list the IP addresses of users who have their respective scheduler disabled (and are currently online)...

script code

:local lname "PPPOE-CLIENT-NOTIFY"
:local uname ""
:local uaddr 0.0.0.0
:local results [:toarray ""]
/ip firewall address-list remove [find where list="PPPOE-CLIENT-NOTIFY"]
/system scheduler
:foreach item in=[find where disabled] do={
    :set uname [get $item name]
    /ppp active
    :set results [find where name=$uname]
    :if ([:len $results] = 1) do={
       :set uaddr [get $results address]
       /ip firewall address-list add list=$lname address=$uaddr comment=$uname
    }
}
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

Re: Help cant create ip address list

Wed Apr 26, 2023 1:39 pm

Thankyou for your response sir Rex 😊😊😊. so much appreciated. The problem is almost identical to my other post
each ppp secret has its own scheduler, if the ppp account scheduler is disabled it will list the ppp active IP of the disabled ppp account to ip address-list notify .

The problem is the last part of the code, it just list the first disabled scheduler and after that the code is discontinued.
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

Re: Help cant create ip address list

Wed Apr 26, 2023 1:40 pm

I haven't tried your revise code sir. Im riding a jeepney going home right now . I'll gonna try it when I'm on my home 😁😁
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

Re: Help cant create ip address list

Sat Apr 29, 2023 6:06 am

Thankyou sir rex! IT works! I can now live happily ever after!

Who is online

Users browsing this forum: No registered users and 14 guests