Script for printing Hotspot Username and Password Only

Автоматизация при помощи встроенного скриптового языка и RouterOS API
JeQuilatan
Сообщения: 4
Зарегистрирован: 20 сен 2022, 17:42

Script for printing Hotspot Username and Password Only

Сообщение JeQuilatan »

I'm currently working on a hotspot project wherein I found and used a script to generate hotspot vouchers (username and password). I also want to print the username and password only on the terminal so I can copy and paste it on excel to make a printable version. Does any one know or have a script where I can extract only the username and password from the hotspot.

Here's the code I tried but unfortunately not working

:local users [/ip hotspot user print as-value];
:foreach user in=users do={
:put ($user->"username");
:put ($user->"password");
};

Thanks
Аватара пользователя
Chupaka
Сообщения: 3526
Зарегистрирован: 29 фев 2016, 15:26
Откуда: Минск

Re: Script for printing Hotspot Username and Password Only

Сообщение Chupaka »

Try something like this:

Код: Выделить всё

/ip hotspot user
:foreach user in=[find] do={
	:put [get $user username];
	:put [get $user password];
};
JeQuilatan
Сообщения: 4
Зарегистрирован: 20 сен 2022, 17:42

Re: Script for printing Hotspot Username and Password Only

Сообщение JeQuilatan »

Hi is it possible for me to show only the username and passwords of all the generated hotspot vouchers

For example as seen from the attached photo I only want to print to the terminal all of the Name and Password columns.

I tried to the code format, but unfortunately it did not return anything.

Thanks
У вас нет необходимых прав для просмотра вложений в этом сообщении.
Аватара пользователя
Chupaka
Сообщения: 3526
Зарегистрирован: 29 фев 2016, 15:26
Откуда: Минск

Re: Script for printing Hotspot Username and Password Only

Сообщение Chupaka »

So, did it work or not? I don't have any Hotspot installations at hand to test on real data.
JeQuilatan
Сообщения: 4
Зарегистрирован: 20 сен 2022, 17:42

Re: Script for printing Hotspot Username and Password Only

Сообщение JeQuilatan »

It did'nt work.

But I'm trying to do now is to run the voucher generating script at the same time it will print the details on the terminal. But when I run it, the terminal is reacting upon adding the new user and password but it shows only blank on the terminal side.

Thanks for your response again
У вас нет необходимых прав для просмотра вложений в этом сообщении.
JeQuilatan
Сообщения: 4
Зарегистрирован: 20 сен 2022, 17:42

Re: Script for printing Hotspot Username and Password Only

Сообщение JeQuilatan »

Hi just for update I just used the same script for generating hotspot username and password but added a :put before the delay line

:for i from 1 to 50 do={
/ip hotspot user add limit-bytes-total=2G server=hotspot1 profile=10M_2D name=("U1G".$i) password=("p$i".[:pick [/system clock get time] 6 8]);
:put ("U1G".$i, ("p$i".[:pick [/system clock get time] 6 8]));
:delay 400ms;
/log info "OK"
};


If you have any idea to simplify my codes or idea to still printing username and password only on the terminal after it was generate. Feel free to correct me.

Thanks and Stay Safe
Аватара пользователя
Chupaka
Сообщения: 3526
Зарегистрирован: 29 фев 2016, 15:26
Откуда: Минск

Re: Script for printing Hotspot Username and Password Only

Сообщение Chupaka »

What exactly didn't work? What did you run, what did you expect and what did you get instead? There are no telepathists.

Now you want to simply create 50 hotspot users with logins "U1G1", "U1G2", "U1G3", ... and passwords "p132", "p232", "p333", ..., right?