Code: Select all
:global filenameIP "iphistory.txt"
:global arrMonths {jan="01";feb="02";mar="03";apr="04";may="05";jun="06";jul="07";aug="08";sep="09";oct="10";nov="11";dec="12"}
{
:local data [/system clock get date]
: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"
:global now "TIME:$mtime DATE: $[:pick $data 4 6]-$($arrMonths->[:pick $data 0 3])-$[:pick $data 7 11]"
}
/file
:if ([:len [find where name="flash" and type="disk"]] = 1) do={:set filenameIP "flash/$filenameIP"}
:if ([:len [find where name=$filenameIP]] = 0) do={print file="$filenameIP"; :delay 5s; set $filenameIP contents=""}
:global currentIP
:local newIP [/ip address get [find interface="ETHERT 1"] address]
:set newIP [:pick $newIP 0 [:find $newIP "/" -1]]
:if ($newIP != $currentIP) do={
/file
:delay 5s
:local filecontent [get $filenameIP contents]
:local newfilecontent "\r\n************************************************************\r\nNEW IP: $newIP\t$now\r\n$filecontent"
set $filenameIP contents=$newfilecontent
:set currentIP $newIP;
}
Code: Select all
:global currentIP
:local newIP [/ip address get [find interface="ETHERT 1"] address]
:set newIP [:pick $newIP 0 [:find $newIP "/" -1]]
:if ($currentIP != $newIP) do={
/tool e-mail send to="XXXXXXX@hotmail.com" subject=[/system identity get name] start-tls=yes \
body=" THIS IS THE NEW IP: $newIP"
set currentIP $newIP
}
EL DONCITO.