Mikrotik script how to line break

Hi, i have this script:
:if ([/ping address=8.8.8.8 count=25]=25) do={

/file set miconexion.txt contents [/system clock get date]

} else={/file set miconexion.txt contents [/system clock get date]}I need line break for each script run like that:
nov/18/2013
nov/18/2013
nov/18/2013
nov/18/2013

And this script only replace the first line for each run..

You need to explicitly add to the contents, rather than replace it. Use the “/file” menu’s “get” command to get the current contents.

i.e.
/file set miconexion.txt contents ([/file get miconexion.txt contents] . “\n” . [/system clock get date])

NICE! The script works, now i need to write a string, i have this:
:if ([/ping address=8.8.8.8 count=25]=25) do={

/file set miconexion.txt contents ([/file get miconexion.txt contents] . “\n” . [/system clock get date] . “_” . [/system clock get time] ."_ ". “Conexion” . )

} else={/file set miconexion.txt contents [/system clock get date]}How i can write strings?

"Conexion"is a string…

So… you know… just change it to whatever you want to write. In the case of the above, you’ve written the word Conexion.

Nice it’s working now, i put the final script, if somebody needs it:
:if ([/ping address=8.8.8.8 count=25]=25) do={

/file set miconexion.txt contents ([/file get miconexion.txt contents] . “\n” . [/system clock get date] . “_” . [/system clock get time] ."_ ". “Conexion”)

} else={/file set miconexion.txt contents [/system clock get date]}

pd: The script didnt run before because i didnt need the last concat ".. ._ “. “Conexion” .)”

Hi again guys, i have a little problem with this script, this is the final code:
:if ([/ping address=8.8.8.8 count=4]=4) do={

/file set miconexion.rsc contents ([/file get miconexion.rsc contents] . “\n” . [/system clock get date] . “_” . [/system clock get time] ."_ ". “Conexion”)

} else={/file set miconexion.rsc contents (“\n” . [/system clock get date] . “_” . [/system clock get time] .“_”. “No hay conexion”)}So, i have this script in a scheduler, every 5 seconds for testing, but i dont know why, this script stop writing in the file or it rewrites the file, erasing all before lines wrote, after X seconds.. :S
Maybe the problem is on the else, but i dont find it..

UPDATE: The script usually stops when the file (miconexion.rsc) reached the ±4000B

Yeah, sadly it’s a known issue with RouterOS… The upper limit is really 4096B (or 4KiB).

The only way to keep a larger file is to simply not use scripting to write it and/or store it. Like, you could perhaps use “/tool fetch” to send the results to an FTP or HTTP server, where the contents would be written on a file there.

“But what about when there’s no connection to the server?” I hear you asking. Well, you could keep a file on the router up until the server is reachable, and as soon as the connection is back on, send the file’s contents, and remove it.

For Python: try to replace ‘\n’ with ‘\r\n’