Kill used Hotspot accounts?

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

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?

A very obvious mistake. Thanks for helping.

Greetings
Marc