Hello everyone, I have a script that creates a monthly file, when the new month starts, the script finds the file of the last period. When this is found the variable is set to “true” and the file is forwarded via email. so far everything works.
I would then like to read from the logs whether the email was sent. if this happens I would like to perform the actions indicated in the following part of the script
I am attaching only the relevant part of the script as the script is very long. therefore the variables recalled by the email sending are all declared and functioning and no syntax errors are found in the script
:foreach item in=[/file find where name="$LastFile"] do={
:set fileReady "true"
:put "File del mese precedente trovato: $LastFile"
}
:put "File pronto per invio $fileReady"
:if ($fileReady = "true") do={
/tool e-mail send to=$email from=[/tool e-mail get value-name=from] server=[/tool e-mail get value-name=server] port=[/tool e-mail get value-name=port] subject="[$NameHotspot - $IDcliente] Sessioni $LastPeriod" file=$LastFile body="Mail periodica del servizio $NameHotspot, in allegato il registro sessioni degli accessi avvenuti nel mese $LastPeriod.
La mail contiene dati sensibili.
Si prega di non rispondere, questa casella di posta non e' gestita"
}
:delay 5s;
:global lastLog2;
:if ([:typeof $lastLog2] != "num") do={:set lastLog2 0}
:local string $1
:if (([:typeof $string] != "str") or ($string = "")) do={ :return "" }
:local lenstr [:len $string]
:local id2num do={:return [:tonum "0x$[:pick $1 1 [:len $1]]"]}
:local msgToFind "sent"
:local variableName false
:put "Ultimo Log $lastLog2"
:put "id [$id2num \$\".id\"]"
:put $lastLog2
/log
:foreach item in=[/log find where (([$id2num $".id"] > $lastLog2) and buffer~"memory" and message~$msgToFind)] do={
:put "Messaggio trovato"
:delay 5s
:foreach a in=[/file find where name=$LastFile] do={
/file remove $LastFile
}
:delay 3s
/log info "FILE INVIATO E RIMOSSO"
:delay 1s
/system script set [find name="$NameScript"] comment=$date;
:set $fileReady "false"
}
}
}