Community discussions

MUM Europe 2020
 
HaPe
Member Candidate
Member Candidate
Topic Author
Posts: 232
Joined: Fri Feb 10, 2012 10:24 pm
Location: Poland

Add variable to the end of a file

Thu Sep 29, 2016 7:19 pm

Hello,

how can I paste a variable to the a file into a new line?
In anticipation on new The Dude release.
 
User avatar
che
Frequent Visitor
Frequent Visitor
Posts: 94
Joined: Fri Oct 07, 2005 1:04 pm

Re: Add variable to the end of a file

Thu Sep 29, 2016 8:37 pm

This is a simple method of appending lines to a file in RouterOS:
:local content [file get YOUR_FILE contents]
:set content ("$content\r\n$YOUR_VARIABLE")
/file set YOUR_FILE contents=$content
Bear in mind there is 4KB size limitation on read/write of files with this method. If you want to overcome 4KB limitation you will have to write more complex routine for manipulating files and variables.

Who is online

Users browsing this forum: No registered users and 18 guests