Community discussions

MikroTik App
 
alixviral
just joined
Topic Author
Posts: 7
Joined: Tue Apr 23, 2024 12:11 pm

Scripting with Date and Time in v7.10

Tue Apr 23, 2024 12:22 pm

i use this secript in v6 And everything is ok. but I got a new router rb4011 with v7.10 so i cant downgrade now my secript wont work
the secript use for changing pppoe user profile
:local dateint do={
:local montharray { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" };
:local days [ :pick $d 4 6 ];
:local month [ :pick $d 0 3 ];
:local year [ :pick $d 7 11 ];
:local monthint ([ :find $montharray $month ]);
:local month ($monthint + 1);
:if ( [len $month] = 1) do={
:local zero "0";
:return [:tonum ("$year$zero$month$days")];
} else={
:return [:tonum ("$year$month$days")];
}
};

:local timeint do={
:local hours [ :pick $t 0 2 ];
:local minutes [ :pick $t 3 5 ];
:return ($hours * 60 + $minutes);
};

:local date [ /system clock get date ];
:local time [ /system clock get time ];
:local today [$dateint d=$date] ;
:local curtime [$timeint t=$time] ;

:foreach i in [ /ppp secret find where profile="1m" ] do={
:local comment [ /ppp secret get $i comment];
:local name1 [ /ppp secret get $i name];
:local gettime [:pick $comment 12 20];
:if ([:pick $comment 3] = "/" and [:pick $comment 6] = "/") do={
:local expd [$dateint d=$comment] ;
:local expt [$timeint t=$gettime] ;
:if (($expd < $today and $expt < $curtime) or ($expd < $today and $expt > $curtime) or ($expd = $today and $expt < $curtime)) do={
/ppp secret set profile=Expired $i ;
/ppp active remove [find where name=$name1];
}
}
}
Last edited by alixviral on Fri Apr 26, 2024 7:23 pm, edited 2 times in total.
 
User avatar
karlisi
Member
Member
Posts: 443
Joined: Mon May 31, 2004 8:09 am
Location: Latvia

Re: Scripting with Date and Time in v7.10

Wed Apr 24, 2024 8:21 am

Who is online

Users browsing this forum: No registered users and 6 guests