Page 1 of 1

ppp secret profile wont set

Posted: Sun Feb 26, 2023 7:20 pm
by akira463
Hello again masters , im here again with another simple question, the problem is ppp secret profile wont set , here's my code
:foreach item in=[/sys sch find] do={
	:if ([/system scheduler get $item disabled] = true) do={
	:local disAcc [/sys sch get $item name]
	:log warning $disAcc
	/ppp secret set $disAcc profile="EXPIRED"
	}
}
please do help , thankyou

Re: ppp secret profile wont set

Posted: Mon Feb 27, 2023 2:00 am
by rextended
I ignore the complex way for do that, for what do but...

The syntax is correct, regardless the revision:

revised code

/system scheduler
:foreach item in=[find] do={
    :if ([get $item disabled]) do={
        :local disAcc [get $item name]
        :log warning $disAcc
        /ppp secret set $disAcc profile="EXPIRED"
    }
}
There can be 3 reason because do not work:
1) The secret $disAcc that have the same identical name of the scheduler do not exist.
2) The profile "EXPIRED" do not exist
3) There are two profile with ambiguos names like EXP / EXPIRED / EXPIRED_test etc.

The 3rd case can be circumvented with:
        /ppp secret set $disAcc profile=[.. profile find where name="EXPIRED"]

Re: ppp secret profile wont set

Posted: Mon Feb 27, 2023 6:13 am
by akira463
as your guess, the problem sir is that the scheduler names is not match with the ppp secret names, so i did revised my code, but still it does not work sir,
/system scheduler
:foreach item in=[find] do={
    :if ([get $item disabled]) do={
        :local disAcc [get $item name]
        /ppp secret
        :local pppList [find]
        :local pppSec [get $pppList name]
        :log warning $pppSec
       	:if ([$disAcc] = [$pppSec]) do={
       	/ppp secret set $pppSec profile="EXPIRED"
       	} else={
       	:log warning "Match not found"
       	}
    }
}

Re: ppp secret profile wont set

Posted: Mon Feb 27, 2023 10:20 am
by rextended
I do not understand why you want change profile on "secret", if the corresponding scheduler are disabled.
What disable the scheduler, can't direcly change the "secret" profile?

Sorry, but without have in front the device, is hard to hypotize some other possble problems.

Must work, check if the name are really identical and do not containing different spaces, fore example
"test ", " test" or "this is a test" (on the last are present 2 spaces between "a" and tets).
Copy & paste the name instead of rewriting that?

Simplified and revised code:
/system scheduler
:foreach item in=[find where disabled] do={
    :local disAcc [get $item name]
    /ppp secret
    :foreach sname in=[find where name=$disAcc] do={
        :log warning "Set $disAcc profile EXPIRED"
        set $sname profile=([.. profile find where name="EXPIRED"]->0)
    }
}
The profile EXPIRED must exist.

Re: ppp secret profile wont set

Posted: Mon Feb 27, 2023 1:20 pm
by akira463
Thankyou sir for answering my question 😊
Profile EXPIRED exist

I have 200 clients in pppoe
The use of scheduler is to check if the client is already paid and also it removes it's ip from restricted-address-list

If the ppp client scheduler is disabled after due date I do like to change its profile from profile=10mbps plan to profile=EXPIRED so that it will filter who's paid and who's not in just one click .

Re: ppp secret profile wont set

Posted: Tue Feb 28, 2023 5:31 pm
by akira463
sorry for the late reply,

Thank you again sir !!! Youre so amazing!!!