Community discussions

MikroTik App
 
pkisistemas2
just joined
Topic Author
Posts: 15
Joined: Wed May 04, 2011 10:25 pm

Variable nightmare

Sun Jun 02, 2013 11:28 pm

Routeos V 5.25

What i want???... a counter of hotspot logins (simple scritpt), really simple (extracted from another post)


Into on-login section of user profile script of hotspot:
/system script run contarusuario;
Into script section, the script named "contarusuario"
:global usuarios;
:set usuarios ($usuarios + 1);
:log info "number of HS logins: $usuarios"
What is the problem???..

1º. If i execute the script manually (into script sections)... the result is as wanted, the variable "usuarios" increase... and can see their values into "environment" sections of scripts.
2º. If i execute manually (into terminal window)... same result, all is ok
3º. But if is executed with hotspot login...
a. Value is always "1", no matter how many logins, and logoff we did, even with two users online, value show to terminal is "1"
b. The variable is not shown into "environment section".
c. Even more... if i execute several times manually the script, i can see the variable increasing... 5,6,7... if i do a login into hotspot.... "1"... but "global" variable remain as previous 7,8,9

Conclusions...
1º. The scripts is executed on login... (as result is showed into terminal).
2º. But the variable created is not global, but local... and afther the job is done, their result is deleted, so results are useless.

How can i solve this trouble?????
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7188
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Variable nightmare

Mon Jun 03, 2013 1:27 pm

For security reasons global variables are global only for particular user (for example "admin" user). Hotspot on-login script owner is not "admin" but internal system user "sys*", so it cannot write value to "admins" variables.
 
pkisistemas2
just joined
Topic Author
Posts: 15
Joined: Wed May 04, 2011 10:25 pm

Re: Variable nightmare

Mon Jun 03, 2013 1:46 pm

So, ¿is there any solution to my small trouble?... is there any way to bypass this limitation???
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7188
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Variable nightmare

Mon Jun 03, 2013 1:52 pm

One workaround is write value to the file and then read content from the file

Who is online

Users browsing this forum: No registered users and 14 guests