Community discussions

MikroTik App
 
alfagius
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 53
Joined: Mon Feb 21, 2011 4:07 pm

"batch file" for user-manager

Fri Feb 22, 2013 2:33 pm

I work in a Hotel Environment, and got user-manager working like a charm, creating tickets and all that - no problems there.

However I have situations, where I have large meetings on conferences, where instead of giving out tickets like it's Christmas, I create one multi-logon user directly onto the Mikrotik's Hotspot user list, and they use that for the events.

Creating one off myself is no big deal, however I'm getting bombarded by these requests weekly, and I have a lot on my plate, so to me it's just an annoying waste of my time.

Is there a way where I can develop a simple file .. being Java, an MS-DOS batch file or something of the sort, that I can give to the Frontdesk people, and all they do is load it, give it a username, and the application talks to the Mikrotik and sends a:
/ip hotspot user add name=batman profile=multipleuser
That "simple". Would make my life sooooo infinitely easier!

I do tinker in Java, but I'm far from a programmer, so the simpler I can get this done, the better :)

Thanks.
 
alfagius
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 53
Joined: Mon Feb 21, 2011 4:07 pm

Re: "batch file" for user-manager

Mon Feb 25, 2013 10:32 am

Really? Nobody? :(
 
User avatar
skot
Long time Member
Long time Member
Posts: 584
Joined: Wed Nov 30, 2011 3:05 am

Re: "batch file" for user-manager

Sat Mar 02, 2013 9:00 am

I have done something similar using a batch file that asks for input and uploads a file.auto.rsc script via ftp to the router. Upon upload, the script is automatically executed. Downside is that router password would be in plain text in the batch file, and with some versions of RouterOS, there is a bug I ran into.

A second option would be creating a program in java/php/C/whatever using the API. Using this method you would have to turn on the API service on each router.

Another option would be to create a custom Webfig skin. They would have to log in via their browser to add the users.
 
alfagius
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 53
Joined: Mon Feb 21, 2011 4:07 pm

Re: "batch file" for user-manager

Sat Mar 02, 2013 10:08 am

I wouldn't mind the password being in plain text.

The way things are set up, unless someone manages to breach Admin access on a domain level, I'll be the only one to see it.
 
User avatar
skot
Long time Member
Long time Member
Posts: 584
Joined: Wed Nov 30, 2011 3:05 am

Re: "batch file" for user-manager

Sat Mar 02, 2013 8:16 pm

Because of the bug I mentioned earlier, the FIRST time this is run, it will not fully work. The script will be uploaded to the router, but it will not execute. Then, after that it will work every time (as long as the script.auto.rsc file exists on the router). MikroTIK confirmed this is a bug, and said they'll fix it. I haven't tested it in any later versions.

batch code

@echo off

:: CONFIG ::::::::::::::::::::::::::::::::::\

set user=username
set pass=password
set ip=192.168.0.1

:: END CONFIG ::::::::::::::::::::::::::::::/


:: Window Attributes
title HOTSPOT
mode CON: cols=40 lines=11

:: menu
echo.
echo  ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
echo  ±                                    ±
echo  ±  ADD Hotspot User                  ±
echo  ±                                    ±
echo  ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
echo.
echo.
for /f %%A in ('"prompt $H &echo on &for %%B in (1) do rem"') do set BS=%%A
set /p input=%BS%  -^> Enter name: 

:: mikrotik script
echo /ip hotspot user add name="%input%" profile=multipleuser>script.auto.rsc

:: ftp commands to upload script
echo user %user%> ftp.dat
echo %pass%>> ftp.dat
echo put script.auto.rsc>> ftp.dat
echo quit>> ftp.dat

:: upload script
ftp -n -s:ftp.dat %ip%> NUL

:: cleanup
del /q ftp.dat
del /q script.auto.rsc
 
alfagius
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 53
Joined: Mon Feb 21, 2011 4:07 pm

Re: "batch file" for user-manager

Sat Mar 02, 2013 8:19 pm

You sir, have my eternal gratitude!

Will give it a spin first thing on Monday, and report back :)
 
User avatar
skot
Long time Member
Long time Member
Posts: 584
Joined: Wed Nov 30, 2011 3:05 am

Re: "batch file" for user-manager

Sun Mar 03, 2013 3:00 am

Cool, let me know how it goes. One thing I realized after posting was that you might need to change the profile in the following line, in case it changes across routers:

batch code

echo /ip hotspot user add name="%input%" profile=multipleuser>script.auto.rsc
 
alfagius
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 53
Joined: Mon Feb 21, 2011 4:07 pm

Re: "batch file" for user-manager

Sun Mar 03, 2013 8:40 am

Yes I figured that one out :)

I got the jist of what's happening in the batch file, so i'll amend as necessary :)
 
javad474
just joined
Posts: 1
Joined: Sun Jul 31, 2016 1:53 pm

Re: "batch file" for user-manager

Sun Jul 31, 2016 2:01 pm

hello
Variations of this user (Batch) group in mikrotik to edit the page Signup?
hellp.........
 
andymack8
just joined
Posts: 2
Joined: Sun Nov 11, 2018 12:05 pm

Re: "batch file" for user-manager

Sun Feb 06, 2022 8:15 pm

Because of the bug I mentioned earlier, the FIRST time this is run, it will not fully work. The script will be uploaded to the router, but it will not execute. Then, after that it will work every time (as long as the script.auto.rsc file exists on the router). MikroTIK confirmed this is a bug, and said they'll fix it. I haven't tested it in any later versions.

batch code

@echo off

:: CONFIG ::::::::::::::::::::::::::::::::::\

set user=username
set pass=password
set ip=192.168.0.1

:: END CONFIG ::::::::::::::::::::::::::::::/


:: Window Attributes
title HOTSPOT
mode CON: cols=40 lines=11

:: menu
echo.
echo  ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
echo  ±                                    ±
echo  ±  ADD Hotspot User                  ±
echo  ±                                    ±
echo  ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
echo.
echo.
for /f %%A in ('"prompt $H &echo on &for %%B in (1) do rem"') do set BS=%%A
set /p input=%BS%  -^> Enter name: 

:: mikrotik script
echo /ip hotspot user add name="%input%" profile=multipleuser>script.auto.rsc

:: ftp commands to upload script
echo user %user%> ftp.dat
echo %pass%>> ftp.dat
echo put script.auto.rsc>> ftp.dat
echo quit>> ftp.dat

:: upload script
ftp -n -s:ftp.dat %ip%> NUL

:: cleanup
del /q ftp.dat
del /q script.auto.rsc
I think this bug was fixed, I can no longer use this trick to upload config

Who is online

Users browsing this forum: No registered users and 6 guests