I have the following scripts that work very well separately, but I would like to make only one and thus be able to keep a record in the file.txt, I don't know if they understand what I want to do.
Thank you in advance for your help.
Code: Select all
:global stopRouterRun false
:do {
:local file "electric-cut.txt"
:local data [/system clock get date]
:global arrMonths
:local day [:pick $data 4 6]
:local mon ($arrMonths->[:pick $data 0 3])
:local year [:pick $data 7 11]
:local date "$day-$mon-$year"
:local itime [/system clock get time]
:local hours [:pick $itime 0 2]
:local minsec [:pick $itime 2 8]
:local mhours [:tonum $hours]
:local msymbl "AM"
:if ($mhours > 11) do={:set msymbl "PM"}
:set mhours ($mhours % 12)
:if ($mhours = 0) do={:set mhours 12}
:if ($mhours < 10) do={:set mhours "0$mhours"}
:local mtime "$mhours$minsec $msymbl"
:local data1 "****************************\r\n court:$date\r\n at: $mtime\r\n****************************"
/file
:if ([:len [find where name=$file]] = 0) do={print file=$file; :delay 2; set $file contents=""}
set $file contents=$data1
:delay 60
} while=(!$stopRouterRun)
Code: Select all
:delay 60
{
:local file "firtsstartup.txt"
:local intGoff [:tonum [/system clock get gmt-offset]]
:if ($intGoff > 86400) do={:set intGoff ((4294967296 - $intGoff) * -1)}
:local epochNow (([/tool fetch url="https://helloacm.com/api/unix-timestamp-converter/\3Fs=now" as-value output=user])->"data")
:local upTime [/system resource get uptime]
:local wPos [:find $upTime "w" -1]
:local dPos [:find $upTime "d" -1]
:local utLen [:len $upTime]
:local utSec [:pick $upTime ($utLen - 2) $utLen]
:local utMin [:pick $upTime ($utLen - 5) ($utLen - 3)]
:local utHou [:pick $upTime ($utLen - 8) ($utLen - 6)]
:local utDay 0
:local utWee 0
:if (([:typeof $wPos] = "nil") and ([:typeof $dPos] = "num")) do={:set utDay [:pick $upTime 0 $dPos] }
:if (([:typeof $wPos] = "num") and ([:typeof $dPos] = "num")) do={:set utDay [:pick $upTime ($wPos + 1) $dPos] }
:if ([:typeof $wPos] = "num") do={:set utWee [:pick $upTime 0 $wPos] }
:local totUtSec ($utSec + (60 * $utMin) + (60 * 60 * $utHou) + (60 * 60 * 24 * $utDay) + (60 * 60 * 24 * 7 * $utWee))
:local epochStart ($epochNow - $totUtSec + $intGoff)
:local datetimeStart (([/tool fetch url="https://helloacm.com/api/unix-timestamp-converter/\3Fs=$epochStart" as-value output=user])->"data")
:set datetimeStart [:pick $datetimeStart 1 ([:len $datetimeStart] - 1)]
:local year [:pick $datetimeStart 0 4]
:local month [:pick $datetimeStart 5 7]
:local day [:pick $datetimeStart 8 10]
:local hms [:pick $datetimeStart 11 19]
:local mhours [:tonum [:pick $hms 0 2]]
:local minsec [:pick $hms 2 8]
:local msymbl "AM"
:if ($mhours > 11) do={:set msymbl "PM"}
:set mhours ($mhours % 12)
:if ($mhours = 0) do={:set mhours 12}
:if ($mhours < 10) do={:set mhours "0$mhours"}
:local date "$day/$month/$year"
:local time "$mhours$minsec $msymbl"
:local started "****************************\r\n date: $date\r\n time: $time\r\n****************************"
/file
:if ([:len [find where name=$file]] = 0) do={print file=$file; :delay 5; set $file contents=""}
set $file contents=$started
}
EL DONCITO.