Community discussions

MikroTik App
 
tiftok
newbie
Topic Author
Posts: 48
Joined: Thu Apr 07, 2016 1:40 pm

User Manager card generate only number from terminal script

Tue Jun 22, 2021 7:18 am

hello in this script :
User Manager card generate only number from terminal script

how to work videos in arabic :
https://www.youtube.com/watch?v=zYaByL0HlPY

how to work videos in english :
https://www.youtube.com/watch?v=a2aA1TAt_4Y

script :
#call $gencard from terminal to run 
# 
##dev : tiftok.com  khaled almalsi https://www.youtube.com/c/TIFTOK
## this script is free 100%
:global read do={:return}
:global profilelist ({});
:global custmerlist ({});
:global cardnumber 0;
:global maxcardnumber 200;
:global profilereadlist do={

 if ([:len $profilelist]=0) do={
 
  :local counter1 0;
:foreach proi in [/tool user-manager profile find ] do={
 :set ($profilelist->$counter1) ([/tool user-manager profile get $proi name]);
 :set $counter1 ($counter1+1);
}


 }
 
}

:global custmerreadlist do={

 if ([:len $custmerlist]=0) do={
 
  :local counter1 0;
:foreach proi in [/tool user-manager customer find ] do={
 :set ($custmerlist->$counter1) ([/tool user-manager customer get $proi login]);
 :set $counter1 ($counter1+1);
}


 }
 
}

:global printprofilelist do={
:put ("-please select the profile name :");

:foreach pnum,pname in $profilelist do={
:put ($pnum."-".$pname);


}
}

:global printcustomerlist do={
:put ("-please select the card  onwer :");

:foreach pnum,pname in $custmerlist do={
:put ($pnum."-".$pname);


}
}
:global chartonum do={
:local cahrarray {0=0;1=1;2=2;3=3;4=4;5=5;6=6;7=7;8=8;9=9;a=1;b=2;c=3;d=4;e=5;f=6;g=7;h=8;i=9;j=10;k=11;l=12;m=13;n=14;o=15;p=16;q=17;r=18;s=19;t=20;u=21;v=22;w=23;x=24;y=25;z=26}
:local output "";
  :for i from=0 to=([:len $mystring] - 1) do={
    :local char [:pick $mystring $i] ;
	 :set $char ($cahrarray->$char)
      :set $output ($output . $char)


  
  }
    :return $output ;



}
:global gencardname do={

:local cardn [pick ([/certificate scep-server otp generate minutes-valid=1 as-value]->"password") 0 8];
 :set cardn ([$chartonum mystring=$cardn]) ;
 :local passwords [pick ([/certificate scep-server otp generate minutes-valid=1 as-value]->"password") 0 4];
 :set passwords ([$chartonum mystring=$passwords]) ;

:local temparray {"un"=$cardn;"pw"=$passwords};
:return $temparray;

}
:global gencard do={
$profilereadlist ;
$custmerreadlist;
:put ("---------wellcome in card generate-------");
$printprofilelist ;
local errors "";
local myselectp 0;
:do {

:put ($errors);
:set myselectp [$read];
:set $errors ("the select profile not valid ");
} while=(($myselectp > ([:len $profilelist]-1)) || ($myselectp < 0));
local errors "";
local myselectc 0;
$printcustomerlist ;
:do {

:put ($errors);

:set myselectc [$read];
:set $errors ("the customer select not valid ");
} while=(($myselectc > ([:len $profilelist]-1)) || ($myselectc < 0));
:put ("-please input card count to generate less than ".$maxcardnumber);

local errors "";

:do {

:put ($errors);

:set cardnumber [$read];
:set $errors ("the card count not valid ");
} while=($cardnumber > $maxcardnumber);

 :local script2write ( "\$cardmake  cu="."\"".($custmerlist->$myselectc)."\""." pr="."\"".($profilelist->$myselectp)."\"");
 :local date [/system clock get date]
:local time [/system clock get time]
:local filec ("cardfile-".[:pick $date 7 11]."-".[:pick $date 0 3]."-".[:pick $date 4 6]."-".[:pick $time 0 2].[:pick $time 3 5].".html")

 :put "ok fine";
  :execute script=$script2write file=$filec; 
}


 :global cardmake do={
  :for i from=1 to=$cardnumber do={
  :local myuser [$gencardname];
  /tool user-manager user add username=($myuser->"un") password=($myuser->"pw")  customer=$cu ;  
  /tool user-manager user create-and-activate-profile numbers=($myuser->"un") profile=$pr customer=$cu ;
  :put ("USER : ".($myuser->"un")." **** PASSWORD: ".($myuser->"pw"));
  :put  ("------------------------------------------");
}
}








Khaled mulsi ->>> I love mikrotik :D --TIFTOK--

Who is online

Users browsing this forum: wmc2014 and 3 guests