I played a little bit, but the only thing I could get is to print one line in the file. Every new line is erasing the previous one.
I tried to copy some lines of code from others, but I really don’t have too much understanding of this.
This is my code: #Global variable
:global fileContent “”; #this commands puts the output of this print command in the file (it erases previous entry in the file)
/interface wireless registration-table print file=Test1.txt brief where mac-address=“xx:xx:xx:xx:xx:xx”; #the content of the files i copied to variable
:set fileContent [/file get Test1.txt content]; #variable is copied to new file, each entry in new line
/file set Signal.txt contents=($fileContent.“\n”);
So this was my logic, but it doesn’t work. I can’t add new row, so every new entry is put in the new row.
You could save signal strength to a variable and append this data every second. Then, this variable can be saved to a file:
{
# check if file exists, if not create it and set contents to nothing
:if ([:len [/file find name="Signal.txt"]] != 1) do={
/file print file=Signal
:delay 2s;
/file set Signal.txt contents="";
}
# set variables
:local fileContent;
:local signal;
# get signal from specific MAC
:set signal [/interface wireless registration-table get [find where mac-address="xx:xx:xx:xx:xx:xx"] signal-strength];
# get file content
:set fileContent [/file get Signal.txt content];
# append signal to fileContent
:set fileContent ($fileContent . $signal);
# re-write file content
/file set Signal.txt contents=($fileContent . "\r\n");
}
However, writing to a file every second may not be advisable as it will shorten the life of the flash memory… You could save the signal to a variable every second and then every few minutes write this data to a file (using a couple scripts and the scheduler). However, the main problem with this method is file size. You can’t create a file larger than 4096 bytes (http://forum.mikrotik.com/t/how-can-i-write-script-output-to-a-file/38551/1), so you will quickly hit that limit.