Community discussions

MikroTik App
 
eldoncito2019
Member
Member
Topic Author
Posts: 333
Joined: Fri Jun 14, 2019 1:07 pm

Files in File

Fri Apr 01, 2022 10:49 pm

Friends, I have the following script:
:local a ("court");
:local data1 (" at: " elaborate script
by: FRANK MU/OZ") ;
/file print file=$a
/file set $a contents=$data1;


and I want it to save a .TXT file to file.

Thank you for your answers.

EL DONCITO.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Files in File

Sat Apr 02, 2022 12:02 am

this is invalid:
:local data1 (" at: " elaborate script
by: FRANK MU/OZ") ;

elaborate script ????

also put the script inside code blocks

What mean:
"and I want it to save a .TXT file to file" ???


At the end of this:
{
:local a "court"
:local data1 "do not write random text and call it script"
/file
print file="$a"
set $a contents=$data1
}
the file court.txt is created.


And for do something better, if the file must persist on reboot, this create the file inside flash disk on Flash devices without modifing the script when used on NAND devices.
{
:local a "court"
:if ([:len [/file find where name="flash" and type="disk"]]=1) do={:set a "flash/$a"}
:local data1 "do not write random text and call it script"
/file
print file="$a"
set $a contents=$data1
}
Last edited by rextended on Mon Apr 04, 2022 7:00 pm, edited 1 time in total.
 
eldoncito2019
Member
Member
Topic Author
Posts: 333
Joined: Fri Jun 14, 2019 1:07 pm

Re: Files in File

Sat Apr 02, 2022 4:44 pm

this is invalid:
:local data1 (" at: " elaborate script
by: FRANK MU/OZ") ;

elaborate script ????

also put the script inside code blocks

What mean:
"and I want it to save a .TXT file to file" ???


At the end of this:
{
:local a "court"
:local data1 "do not write random text and call it script"
/file
print file="$a"
set $a contents=$data1
}
the file court.txt is created.


And for do something better, if the file must persist on reboot, this create the file inside flash disk on Flash devices without modifing the script when used on NAND devices.
{
:global Gprfx ""
:if ([:len [/file find where name="flash" and type="disk"]]=1) do={:set Gprfx "/flash"}
:local a "$Gprfx/court"
:local data1 "do not write random text and call it script"
/file
print file="$a"
set $a contents=$data1
}
Very grateful for your answer friend, now how do I place the script as you have it here, shaded in blue, I don't know much about the forum

EL DONCITO.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Files in File

Sat Apr 02, 2022 5:02 pm

Select a text and click on [] icon
 
eldoncito2019
Member
Member
Topic Author
Posts: 333
Joined: Fri Jun 14, 2019 1:07 pm

Re: Files in File  [SOLVED]

Sat Apr 02, 2022 5:30 pm

Select a text and click on [] icon
:local a ("court");
:local data1 (" at: " elaborate script
by: FRANK MU/OZ") ;
/file print file=$a
/file set $a contents=$data1;
Very grateful friend


EL DONCITO.

Who is online

Users browsing this forum: No registered users and 25 guests