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

ppp secret profile wont set

Sun Feb 26, 2023 7:20 pm

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
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ppp secret profile wont set

Mon Feb 27, 2023 2:00 am

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"]
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

Re: ppp secret profile wont set

Mon Feb 27, 2023 6:13 am

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"
       	}
    }
}
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ppp secret profile wont set

Mon Feb 27, 2023 10:20 am

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.
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

Re: ppp secret profile wont set

Mon Feb 27, 2023 1:20 pm

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 .
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

Re: ppp secret profile wont set

Tue Feb 28, 2023 5:31 pm

sorry for the late reply,

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

Who is online

Users browsing this forum: No registered users and 16 guests