hello ,
I have connected a device that send me log.txt file to the RB using FTP.
how can I write a script that whenever the file is copied he will send it to me to mail?
how do I make the script “choose” the latest file that was created?
and them continue to other file ,and so on and on…
I have try to get the file name by using this command :
:put [/file get [find where creation-time=dec/18/2013 15:45:48] name ]
but I get no such file… (although I have this file )
the file name is changing according to the time it’s been created
for ex -
FTP_2013-12-18-_14-41-55_142.log
FTP_2013-12-18-_14-42-02_632.log
if I have 10 files with different creation-time , how do I make him send me every time the oldest he didn’t send ?
let me give an example -
I have 10 file with different name\creation-time .
I need to know when it was the last time he send a file - the it will save it in variable “old_time”
and then it will run all the files until he find a file with newer creation-time ,send it -and change “old_time”
the script will run every 1 min , one time.
hope it’s clear
Thanks for the help ,
what you said about the quote did help - so manually I can see what is the last one and send it
:global new [/file get [find where creation-time="dec/18/2013 17:39:45"] name];
:log warning "New file";
tool e-mail send to="MyEmail@gmail.com" subject="LOG file " tls=yes from=Unit1" body="lof file" file=$new;
:log warning "E-mail send";
:log warning "************";
this is what I have done so far
I decided to run by number of file and always see what is file number 0 and compare it to a file with the last name
call LastFile.txt
:global new [/file get number=0 name] ;
:global old [/file get Last/LastFile.txt content];
if ($old=$new ) do={:log warning message="No need to send" ;set old ($new ); file set [file find name=Last/LastFile.
txt] contents=$new ;/file remove [find name=$new]} else={:log warning message="NEED To SEND MAIL!!!!!!";/system script run mail; file set [find name=Last/LastFile.txt] contents=$new ; /file remove [find name=$new]}
but it not always working for me
I have have 10 files and I get always “no need to send” , why is it ?
also when I run the command manually one by one it’s working …
This is how I would do it. This script stores the “date/time stamp” into the schedule’s comment field (to survive reboots, which a global variable won’t do). It gets the date and time values from the comment and then checks all “FTP…log” files for any that are newer, and sends email if any are found. Make sure to change the first line to be the schedule you want to store the variable in. I adapted this from another script found here: http://forum.mikrotik.com/t/compare-dates/53609/1
:local scheduleName “checkFTPlogs”