Code: Select all
:global interfaceIP "ETHERT 1"
:global filenameIP "historial de IPs.txt"
:global arrMonths {jan="ENE";feb="FEB";mar="MAR";apr="ABR";may="MAY";jun="JUN";jul="JUL";aug="AGO";sep="SEP";oct="OCT";nov="NOV";dec="DIC"}
{
:local ndate [/system clock get date]; :local ntime [/system clock get time]
:global now "HORA:$ntime FECHA: $[:pick $ndate 4 6]-$($arrMonths->[:pick $ndate 0 3])-$[:pick $ndate 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
:if ([:len $currentIP] = 0) do={:set currentIP 0.0.0.0/0}
:local newIP [/ip address get [find interface="$interfaceIP"] address]
:set newIP [:pick $newIP 0 [:find $newIP "/" -1]]
:if ($newIP != $currentIP) do={
/file
:delay 5s
:local filecontent [get $filenameIP contents]
:local newfilecontent "NUEVA IP:$newIP\t$now\r\n$filecontent"
set $filenameIP contents=$newfilecontent
:set currentIP $newIP;
}
and this one that sends a new IP address to my email
Code: Select all
:global currentIP;
:local newIP [/ip address get [find interface="ETHERT 1"] address];
:if ($newIP != $currentIP) do={
:local newIP [/ip address get [find interface="ETHERT 1"] address];
/tool e-mail send to="therewasanemailaddress" subject=([/system identity
get name]) body=" Esta es su nueva direccion IP: $newIP" start-tls=yes;
:set currentIP $newIP;
}
When I activate both scripts, the second script that sends the new ip address to my email goes crazy and sends the ip address every 10 seconds, as I have it programmed. Thanks for your help.
EL DONCITO.