Page 1 of 1

Help cant create ip address list

Posted: Tue Apr 25, 2023 5:34 pm
by akira463
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

Re: Help cant create ip address list

Posted: Tue Apr 25, 2023 8:38 pm
by rextended
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
    }
}

Re: Help cant create ip address list

Posted: Wed Apr 26, 2023 1:39 pm
by akira463
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.

Re: Help cant create ip address list

Posted: Wed Apr 26, 2023 1:40 pm
by akira463
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 😁😁

Re: Help cant create ip address list

Posted: Sat Apr 29, 2023 6:06 am
by akira463
Thankyou sir rex! IT works! I can now live happily ever after!