Community discussions

MikroTik App
 
truzicka
just joined
Topic Author
Posts: 7
Joined: Thu Dec 08, 2005 5:16 pm

Hotspot User profile On Login: script tab variable

Tue Feb 07, 2012 7:52 am

It shows in the user manual that you can use
:log info "User $user logged in!"
This send the user logging into the log. My question is there also a way to logging the user's MAC as well in this script?
 
c0w
just joined
Posts: 6
Joined: Wed May 09, 2012 2:06 pm

Re: Hotspot User profile On Login: script tab variable

Wed May 09, 2012 2:11 pm

I'm currently running 5.15 and i've enabled the on-login in the profile.
 0   name="douser" owner="admin" policy=read,write,policy,test,password,sniff,sensitive last-started=may/09/2012 12:04:07 run-count=50 source=
       {
       :log info "User $user logged in!"
       }
 0   name="douser" owner="admin" policy=read,write,policy,test,password,sniff,sensitive last-started=may/09/2012 12:04:07 run-count=50 source= :log info "User $user logged in!"
none of the above work they all error on the $user variable. Could someone shed some light on this?

thanks
 
Devil
Member Candidate
Member Candidate
Posts: 170
Joined: Thu Jul 21, 2011 9:13 am

Re: Hotspot User profile On Login: script tab variable

Wed May 09, 2012 3:46 pm

My question is there also a way to logging the user's MAC as well in this script?
try this:
:local "hotspot_user" $user; :log info "User $user with mac-address of $[/ip hotspot active get [find user=$"hotspot_user"] mac-address] logged in!"
none of the above work they all error on the $user variable.
$user is a local variable, it will not work if you call it from another script. it should be directly used in on-login and on-logout section.
 
c0w
just joined
Posts: 6
Joined: Wed May 09, 2012 2:06 pm

Re: Hotspot User profile On Login: script tab variable

Wed May 09, 2012 4:15 pm

@Devil,

Thanks for the quick response however its still not working.

I tried the following (executing them from command line does not work I accept the reason for that is $user is only defined during the on-login process).

Basically nothing appears in the log, is there maybe a way to debug the script process?


All seem to fail.
:log info "User $user logged in!"
:local "hotspot_user" $user; 
:log info "User $user with mac-address of $[/ip hotspot active get [find user=$"hotspot_user"] mac-address] logged in!"
 {
       :log info "User $user logged in!"
 }
 
Devil
Member Candidate
Member Candidate
Posts: 170
Joined: Thu Jul 21, 2011 9:13 am

Re: Hotspot User profile On Login: script tab variable

Wed May 09, 2012 4:28 pm

I tried the following (executing them from command line does not work I accept the reason for that is $user is only defined during the on-login process).
You got it all wrong. you can only use $user in on-login and on-logout section. not from command line and not from another script.
open you winbox, go to ip -> hotspot , go to 'user profile' tab, open the default profile for example, go to the 'Scripts' tab. that's were you should put your script for on-login and on-logout.
 
c0w
just joined
Posts: 6
Joined: Wed May 09, 2012 2:06 pm

Re: Hotspot User profile On Login: script tab variable

Wed May 09, 2012 4:39 pm

Ahhhh,

Penny just dropped right you need to put the actual script there!.

right let me just test.

thanks very much Devil.

update.

tested and working. thank you very much!.
 
Devil
Member Candidate
Member Candidate
Posts: 170
Joined: Thu Jul 21, 2011 9:13 am

Re: Hotspot User profile On Login: script tab variable

Wed May 09, 2012 4:46 pm

Sure. however, that $user variable, seems to be quite delicate . sometimes you have to put its value to another variable to make things work. look at my script, that how i created "hotpot_user". putting $user there directly, simply didn't work. I'm not quite sure why. but at least there's a workaround for it.
 
c0w
just joined
Posts: 6
Joined: Wed May 09, 2012 2:06 pm

Re: Hotspot User profile On Login: script tab variable

Wed May 09, 2012 5:05 pm

I had done all the hard bits I needed for the script i just couldn't get the damn $user variable to populate. so thank you very much for pointing out to put the script there and not create a script =)
 
c0w
just joined
Posts: 6
Joined: Wed May 09, 2012 2:06 pm

Re: Hotspot User profile On Login: script tab variable

Thu Jun 14, 2012 12:51 pm

@devil,

I've been doing some testing on the RB1100Hx2 and I've found an odd thing.

Is the "On Login" applied per user?

What I am seeing is it only running on the first user that logs in on the hotspot.

Thanks
 
Devil
Member Candidate
Member Candidate
Posts: 170
Joined: Thu Jul 21, 2011 9:13 am

Re: Hotspot User profile On Login: script tab variable

Thu Jun 14, 2012 1:13 pm

No. it should run for each user. make sure all the users are using the same profile that you set On-Login on. maybe there's something wrong in your script. if you are sure you're doing everything right, contact the support.
 
mitry
just joined
Posts: 23
Joined: Tue Jun 26, 2012 10:06 pm

Re: Hotspot User profile On Login: script tab variable

Mon Jul 09, 2012 11:30 pm

@Devil, thank you for the tip with $user, i spend few hours before find this thread.
With ROS 5.18 is same - in complicated scripts this variable SOMETIMES does not work.
 
Devil
Member Candidate
Member Candidate
Posts: 170
Joined: Thu Jul 21, 2011 9:13 am

Re: Hotspot User profile On Login: script tab variable

Tue Jul 10, 2012 9:53 am

Glad i could help :)

Who is online

Users browsing this forum: CGGXANNX, mkx, mvz71, okw, yakovz and 90 guests