Page 1 of 1

Kill used Hotspot accounts?

Posted: Sun Feb 01, 2009 12:28 am
by Zugschlus
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

Re: Kill used Hotspot accounts?

Posted: Sun Feb 01, 2009 10:18 am
by SurferTim
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?

Re: Kill used Hotspot accounts?

Posted: Wed Feb 04, 2009 8:35 pm
by Zugschlus
A very obvious mistake. Thanks for helping.

Greetings
Marc