Community discussions

MikroTik App
 
reza.mnp
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 90
Joined: Mon Jun 11, 2007 9:44 am
Location: ilam - iran
Contact:

writing a script to change ip-binding type

Wed Sep 16, 2009 9:45 pm

i want write a scripte that
if ip hostpot ip-binding type = regular and server ="x" or "y"
then change to ip hostpot ip-binding type = regular.

thanx.
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: writing a script to change ip-binding type

Wed Sep 16, 2009 10:09 pm

So you basically want to change the "server" property to a value of "all"?
:foreach user in=[/ip hotspot ip-binding find server=x] do={ /ip hotspot ip-binding set $user server=all }; :foreach user in=[/ip hotspot ip-binding find server=y] do={ /ip hotspot ip-binding set $user server=all }
 
reza.mnp
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 90
Joined: Mon Jun 11, 2007 9:44 am
Location: ilam - iran
Contact:

Re: writing a script to change ip-binding type

Sat Sep 19, 2009 5:54 am

:foreach user in=[/ip hotspot ip-binding find server=101] do={ /ip hotspot ip-binding set $user type=regular };

this script not work!


"
[nimda@***] > system script run ip-bindig [above script]
input does not match any value of server
"
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: writing a script to change ip-binding type

Sat Sep 19, 2009 6:55 am

You'd get that output if you don't actually have a hotspot server called 101 by name.

Post the output of
/ip hotspot print
 
reza.mnp
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 90
Joined: Mon Jun 11, 2007 9:44 am
Location: ilam - iran
Contact:

Re: writing a script to change ip-binding type

Sat Sep 19, 2009 11:21 am

Flags: X - disabled, I - invalid, S - HTTPS
# NAME INTERFACE ADDRESS-POOL PROFILE IDLE-TIMEOUT
0 hs-101 - f... 101 101 101 none
1 hs-115 - ... 115 115 115 5m
2 hs-117 - ... 117 117 117 5m
3 hs-118 - ... 118 118 118 5m
4 hs-123 - s... 123 123 123 5m
5 hs-140 - ... 140 140 140 none
6 hs-180 - ... 180 180 180 none
7 hs-127 127 127 127 none
8 hs-170 - a... 170 170 170 10h
9 hs-122 - a... 122 122 122 none
10 hs-107 - l... 107 107 107 none
11 hs-141 - cc 141 141 141 none
12 hs-125 - s... 125 125 125 none
13 hs-160 - t... 160 160 160 none
14 hs-142 142 142 142 none
15 hs-112 - ... 112 12 112 5m
16 hs-113 - p... 113 113 113 none

i want change servertype [regular - bypass - block]
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: writing a script to change ip-binding type

Sat Sep 19, 2009 8:05 pm

So did you try using the server name? Your output shows the server is 'hs-101' and not '101' so you'd use
:foreach user in=[/ip hotspot ip-binding find server=hs-101] do={ /ip hotspot ip-binding set $user type=regular };
and not
:foreach user in=[/ip hotspot ip-binding find server=101] do={ /ip hotspot ip-binding set $user type=regular };
Did you try that? Did it work?
 
reza.mnp
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 90
Joined: Mon Jun 11, 2007 9:44 am
Location: ilam - iran
Contact:

Re: writing a script to change ip-binding type

Sat Sep 19, 2009 9:59 pm

than you that ok.