Community discussions

MikroTik App
 
Zugschlus
just joined
Topic Author
Posts: 10
Joined: Tue Mar 11, 2008 6:58 pm

Kill used Hotspot accounts?

Sun Feb 01, 2009 12:28 am

Hi,

I would like to write a script which automatically kills all Hotspot accounts that were used (uptime != 0) since the script was last called. Unfortunately, I seem to still have some issues understanding the scripting language.

Here is what I have today:
[admin@microtik] /ip hotspot user> /system script print
Flags: I - invalid
0   name="kill-used-wlan-accounts" owner="admin" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff
     last-started=jan/20/2009 15:12:00 run-count=31 source=
       :foreach a in=[/ip hotspot user find uptime!=0 ] do={
         :put $a
         :put [/ip hotspot get $a name]
       }
[admin@microtik] /ip hotspot user> /system script run 0
*1
211AuthHot
*cb

*cc

*cd

*ce

*cf

*d0

*13a

[admin@microtik] /ip hotspot user>  
I guess that my $a doesn't get assigned a value which can be used in the /ip hotspot user get command, but where does the "211WLANHot", which is a value from the "profile" column of my user list, come from?

Can anybody please enlighten me? Thanks in advanced.

Greetings
Marc
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: Kill used Hotspot accounts?

Sun Feb 01, 2009 10:18 am

I think it should be this:
       :foreach a in=[/ip hotspot user find uptime!=0 ] do={
         :put $a
         :put [/ip hotspot user get $a name]
       }
BTW, the :put command will not work run as a service, only in a shell.
In your version, it appears to ignore the asterisk (*) and use just the 1 in the first pass through the loop. I presume that hotspot name is listed as line 1 if you do a print, correct?
 
Zugschlus
just joined
Topic Author
Posts: 10
Joined: Tue Mar 11, 2008 6:58 pm

Re: Kill used Hotspot accounts?

Wed Feb 04, 2009 8:35 pm

A very obvious mistake. Thanks for helping.

Greetings
Marc