LINUX_SRV Telegram 312
Скриптик переустановки пароля пользователя MikroTik

# Скрипт смены пароля пользователя
# только для исполнения в терминале ROS
# by Sertik 09/06/2020

{
:global EnterString do={
:local cont 0; :local string ""
:while ($cont!=13) do={
:local key ([:terminal inkey])
:if ($key!=13) do={
:local char [[:parse "(\"\\$[:pick "0123456789ABCDEF" (($key >> 4) & 0xF)]$[:pick "0123456789ABCDEF" ($key & 0xF)]\")"]]
:set string ("$string"."$char")}
:set cont $key
}
:return $string}
;
:put "Please, enter Username:"
:local RegUser [$EnterString];
:put "";
:if ([:len [/user find disabled=no name=$RegUser]]!=0) do={:put "Ok, a user with this name was found"; :put "";
:put "Please, enter new password for this user:"
:local newPass [$EnterString];
[/user remove $RegUser];
[/user add name=$RegUser password=$newPass group=full];
:put "";
:put "The user has been re-created, the password has been changed";
:put ("New user`s password: "."$newPass");
:put "Don't forget to set up access restrictions based on ip addresses";
} else={:put ("User "."$RegUser "."not found"); :put "";
}
}

Скрипт интересен строкой преобразования кода символа из переменной $key, сграбленного с клавиатуры терминала, в сам символ.

:local char [[:parse "(\"\\$[:pick "0123456789ABCDEF" (($key >> 4) & 0xF)]$[:pick "0123456789ABCDEF" ($key & 0xF)]\")"]]



tgoop.com/linux_srv/312
Create:
Last Update:

Скриптик переустановки пароля пользователя MikroTik

# Скрипт смены пароля пользователя
# только для исполнения в терминале ROS
# by Sertik 09/06/2020

{
:global EnterString do={
:local cont 0; :local string ""
:while ($cont!=13) do={
:local key ([:terminal inkey])
:if ($key!=13) do={
:local char [[:parse "(\"\\$[:pick "0123456789ABCDEF" (($key >> 4) & 0xF)]$[:pick "0123456789ABCDEF" ($key & 0xF)]\")"]]
:set string ("$string"."$char")}
:set cont $key
}
:return $string}
;
:put "Please, enter Username:"
:local RegUser [$EnterString];
:put "";
:if ([:len [/user find disabled=no name=$RegUser]]!=0) do={:put "Ok, a user with this name was found"; :put "";
:put "Please, enter new password for this user:"
:local newPass [$EnterString];
[/user remove $RegUser];
[/user add name=$RegUser password=$newPass group=full];
:put "";
:put "The user has been re-created, the password has been changed";
:put ("New user`s password: "."$newPass");
:put "Don't forget to set up access restrictions based on ip addresses";
} else={:put ("User "."$RegUser "."not found"); :put "";
}
}

Скрипт интересен строкой преобразования кода символа из переменной $key, сграбленного с клавиатуры терминала, в сам символ.

:local char [[:parse "(\"\\$[:pick "0123456789ABCDEF" (($key >> 4) & 0xF)]$[:pick "0123456789ABCDEF" ($key & 0xF)]\")"]]

BY Типичный Сисадмин


Share with your friend now:
tgoop.com/linux_srv/312

View MORE
Open in Telegram


Telegram News

Date: |

With the “Bear Market Screaming Therapy Group,” we’ve now transcended language. Add up to 50 administrators The court said the defendant had also incited people to commit public nuisance, with messages calling on them to take part in rallies and demonstrations including at Hong Kong International Airport, to block roads and to paralyse the public transportation system. Various forms of protest promoted on the messaging platform included general strikes, lunchtime protests and silent sit-ins. Don’t publish new content at nighttime. Since not all users disable notifications for the night, you risk inadvertently disturbing them. On June 7, Perekopsky met with Brazilian President Jair Bolsonaro, an avid user of the platform. According to the firm's VP, the main subject of the meeting was "freedom of expression."
from us


Telegram Типичный Сисадмин
FROM American