Community discussions

MikroTik App
 
andrescamino
Member Candidate
Member Candidate
Topic Author
Posts: 198
Joined: Wed Aug 19, 2009 7:07 pm
Location: Guayaquil-Ecuador

Insert into text file some text from a script

Thu Dec 23, 2010 7:15 pm

Hello,

How can I insert into a text file some information for example I would like to insert into different lines the numbers 1 to 10 into a text file and save it into the files.
/file print file=Number
/file set Number.txt contents=" " 
:for i from=1 to=10 do={ :put $i }
but instead of showing that on the terminal everytime I run it...I would like it to be saved on the contents of Number file in different lines...
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7056
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Insert into text file some text from a script

Thu Dec 23, 2010 7:20 pm

{
 :local tmp "";
 /file print file=Number

 :for i from=1 to=10 do={ :set tmp "$tmp\r\n$i" }
 /file set Number.txt contents=$tmp 
}

 
andrescamino
Member Candidate
Member Candidate
Topic Author
Posts: 198
Joined: Wed Aug 19, 2009 7:07 pm
Location: Guayaquil-Ecuador

Re: Insert into text file some text from a script

Thu Dec 23, 2010 7:29 pm

Tks mrz...it works just like i wanted..

Who is online

Users browsing this forum: brunolabozzetta, Pilo2710 and 29 guests