Community discussions

MikroTik App
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 127
Joined: Fri Apr 19, 2013 9:28 am

disable rules by comment  [SOLVED]

Fri Sep 07, 2018 4:41 am

how to disable comment from 1 to 720
i create the script but its not working.

:if ($Comment=1-720) do={
: log info " the user: $User has Temporary Disconnected!"
[ /ppp secret disable $i ]
[ /ppp active remove [find name=$User] ]

.
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: disable rules by comment

Fri Sep 07, 2018 9:35 am

:do {/ppp secret
 :foreach ix in=[find where (comment>"0" && comment<"721")] do={ 
  :local sNAME [get $ix name];
  disable $ix;
  :log warning message=("The user: " . $sNAME . " has Temporary Disconnected!");
  :do {/ppp active remove numbers=[find where name=$sNAME]
  } on-error={:log error message=("Disconnecting " . $sNAME . " Failed");}
}
} on-error={:log error message="script failed..."}
Last edited by ADahi on Sun Sep 09, 2018 3:07 pm, edited 4 times in total.
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 127
Joined: Fri Apr 19, 2013 9:28 am

Re: disable rules by comment

Fri Sep 07, 2018 6:03 pm

wow thats great but i have problem in the script sir
all of my users where remove after the script is run
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: disable rules by comment

Fri Sep 07, 2018 6:14 pm

Well, what was your question?
Last edited by ADahi on Fri Sep 07, 2018 8:30 pm, edited 1 time in total.
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 127
Joined: Fri Apr 19, 2013 9:28 am

Re: disable rules by comment

Fri Sep 07, 2018 6:19 pm

wow thats great but i have problem in the script sir
all of my users where remove after the script is run
after i run the script sir all my users were disable even there is no comment attached on thier name
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: disable rules by comment

Fri Sep 07, 2018 6:22 pm

okay wait i will fix it
Last edited by ADahi on Fri Sep 07, 2018 8:30 pm, edited 1 time in total.
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: disable rules by comment

Fri Sep 07, 2018 6:28 pm

updated, check it
Last edited by ADahi on Fri Sep 07, 2018 8:30 pm, edited 1 time in total.
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 127
Joined: Fri Apr 19, 2013 9:28 am

Re: disable rules by comment

Fri Sep 07, 2018 6:35 pm

thanks u sir ur superb.
last sir. how can i send the name and remote address in firewall address list after the time comment is 0
coming from ppp secret

example
in firewall address list
name: reminder customer
addrss: ip from remote address in ppp secret
comment: name of my user in ppp secret
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: disable rules by comment

Fri Sep 07, 2018 7:18 pm

try with
You do not have the required permissions to view the files attached to this post.
Last edited by ADahi on Fri Sep 07, 2018 8:29 pm, edited 1 time in total.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3343
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: disable rules by comment

Fri Sep 07, 2018 8:25 pm

@ADahi
Pleas stop quoting the whole post above you.
Click Post Reply in bottom of post.
Quote only what is needed. (part of post)
You only make it harder to read.
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: disable rules by comment

Fri Sep 07, 2018 8:36 pm

@Jotne
are you PHP web designer?
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3343
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: disable rules by comment

Fri Sep 07, 2018 9:57 pm

No I am not
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 127
Joined: Fri Apr 19, 2013 9:28 am

Re: disable rules by comment

Sat Sep 08, 2018 1:00 am

try with
i tried it sir but the problem is even the comment is not 0 the remote ip is still there.
i need it to show the remote ip in firewall/address list when comment become 0 in ppp/secret.
thanks sir
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: disable rules by comment

Sat Sep 08, 2018 11:17 am

Updated working
:do {/ppp secret
:local LIST "reminder";
 :foreach ix in=[find where comment="0"] do={
  :local sNAME [get $ix name];
  :if ([/ppp active find where name=$sNAME]!="") do={
   :local IPadd [/ppp active get number=[find where name=$sNAME] address];
   :do {/ip firewall address-list 
   add list=$LIST address=$IPadd comment=$sNAME
   } on-error={:log error message=("move address of " . $sNAME . " to address-list failed, maybe exist")}
  }
 } 
} on-error={:log error message="script failed..."}
Last edited by ADahi on Sat Sep 08, 2018 6:22 pm, edited 1 time in total.
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: disable rules by comment

Sat Sep 08, 2018 11:19 am

No I am not
I'm looking for PHP web designer
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 127
Joined: Fri Apr 19, 2013 9:28 am

Re: disable rules by comment

Sat Sep 08, 2018 11:29 am

not working sir theres no creation of ip and name in reminder in firewall addres list also i see in logs "script failed"
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: disable rules by comment

Sat Sep 08, 2018 6:22 pm

@runbound
updated check it again
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 127
Joined: Fri Apr 19, 2013 9:28 am

Re: disable rules by comment

Sat Sep 08, 2018 6:47 pm

thank you sir its working now. so helpful. thank you very very very very much
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 127
Joined: Fri Apr 19, 2013 9:28 am

Re: disable rules by comment

Sat Sep 08, 2018 7:07 pm

thank you sir its working now. so helpful. thank you very very very very much
sir one more please
is it possible to send email to my subscriber to inform that they thier subscription is nearly expire because in ppp secret theres no email box there
so possible is write it in a comment like
0 / xxxx@gmail.com
where 0 is my expiration
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: disable rules by comment

Sat Sep 08, 2018 7:43 pm

why not, explain your project in detail
 
netflow
Frequent Visitor
Frequent Visitor
Posts: 94
Joined: Sat Oct 01, 2016 3:53 pm

Re: disable rules by comment

Sat Sep 08, 2018 8:37 pm

To answer your first question, why not simply use?
/ppp secret disable [find where comment>="1" and comment<="720"]
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 127
Joined: Fri Apr 19, 2013 9:28 am

Re: disable rules by comment

Sun Sep 09, 2018 2:41 am

@runbound
updated check it again
1. @ADahi sir is it possible to update only 1ip in firewall addresslist under the comment name coming from ppp secret from his latest ip address
2. how can i send one time mail to my email and to my client email address
i have to email the client 3 days before the comment becomes 0

:do {/ppp secret
:local LIST "Reminder_Customer";
:foreach ix in=[find where (comment>"-30" && comment<"0")] do={
:local sNAME [get $ix name];
:if ([/ppp active find where name=$sNAME]!="") do={
:do {/tool e-mail send to="xxx@yahoo.com" subject="$sNAME" body="Temporary Disconnected" start-tls=yes}
:local IPadd [/ppp active get number=[find where name=$sNAME] address];
:do {/ip firewall address-list
add list=$LIST address=$IPadd comment=$sNAME
} on-error={:log error message=("move address of " . $sNAME . " to address-list failed, maybe exist")}
}
}
} on-error={:log error message="script failed..."}
You do not have the required permissions to view the files attached to this post.
Last edited by runbound on Sun Sep 09, 2018 4:35 am, edited 1 time in total.
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: disable rules by comment

Sun Sep 09, 2018 5:27 am

@runbound
You are going to make things complicated, I recommend you use RADIUS
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 127
Joined: Fri Apr 19, 2013 9:28 am

Re: disable rules by comment

Sun Sep 09, 2018 5:52 am

@ADahi
thanks sir how about question1 sir can u help me with that to work
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: disable rules by comment

Sun Sep 09, 2018 6:44 am

you welcome
:do {/ppp secret
:local LIST "reminder";
 :foreach ix in=[find where comment="0"] do={
  :local sNAME [get $ix name];
  :if ([/ppp active find where name=$sNAME]!="") do={
   :local IPadd [/ppp active get number=[find where name=$sNAME] address];
   :do {/ip firewall address-list 
   remove numbers=[find where comment=$sNAME && list=$LIST];
   add list=$LIST address=$IPadd comment=$sNAME;
   } on-error={:log error message=("move address of " . $sNAME . " to address-list failed")}
  }
 } 
} on-error={:log error message="script failed..."}
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 127
Joined: Fri Apr 19, 2013 9:28 am

Re: disable rules by comment

Sun Sep 09, 2018 7:04 am

thank u very much for the time you gave to me sir. i so much appreciated. do you have email sir if i have offer for u
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: disable rules by comment

Sun Sep 09, 2018 7:08 am

I know you'd do the same for me. :wink:
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 127
Joined: Fri Apr 19, 2013 9:28 am

Re: disable rules by comment

Sun Sep 09, 2018 1:00 pm

sir @ADahi can you help me again
remember the comment sir from 30 down to 0 and its moving according to my script.
how to add the name TEMP beside those numbers where numbers is moving

i try to add temp in comment but the problem is the numbers in comment not moving anymore

Who is online

Users browsing this forum: No registered users and 9 guests