Community discussions

 
ditonet
Forum Veteran
Forum Veteran
Topic Author
Posts: 841
Joined: Mon Oct 19, 2009 12:52 am
Location: Europe/Poland/Konstancin-Jeziorna
Contact:

How to copy file ?

Fri Nov 20, 2009 12:46 am

Hello,

I'm new to MikroTik and ROS, so this is probably lame question. How to copy file using script? I want to make copy of log file located on microSD, but I don't know how to do this :(

Regards, Grzegorz.
Grzegorz | MTCNA, MTCRE, MTCSE | konsultacje MikroTik Warszawa
It is a book about a Spanish guy called Manual. You should read it. - Dilbert
 
fewi
Forum Guru
Forum Guru
Posts: 7734
Joined: Tue Aug 11, 2009 3:19 am

Re: How to copy file ?

Fri Nov 20, 2009 1:05 am

There is no functionality for directly copying a file. If the source file size is under 4096 bytes, you can use something along the lines of the below structure to first read the file into a variable, and then create a new file and set its contents to that variable. Variables are restricted to 4096 bytes so anything larger will not work.
:local sourceFile "test.txt";
:local destinationFile "test2.txt";

:local buffer [/file get [/file find name="$sourceFile"] contents];
/file print file=$destinationFile;
/file set "$destinationFile" contents="$buffer"
 
ditonet
Forum Veteran
Forum Veteran
Topic Author
Posts: 841
Joined: Mon Oct 19, 2009 12:52 am
Location: Europe/Poland/Konstancin-Jeziorna
Contact:

Re: How to copy file ?

Fri Nov 20, 2009 1:22 am

@fewi
Thanks for your quick answer. Unfortunately, file size is bigger than 4096 bytes, so I can't use variables. I must find different solution of my problem, which is not too big at all :D

Thanks again, Grzegorz.
Grzegorz | MTCNA, MTCRE, MTCSE | konsultacje MikroTik Warszawa
It is a book about a Spanish guy called Manual. You should read it. - Dilbert
 
el berto
Member Candidate
Member Candidate
Posts: 197
Joined: Wed Sep 26, 2007 10:53 am

Re: How to copy file ?

Wed May 17, 2017 4:19 pm

To copy/rename bigger files I use fetch (x example to copy firmware among RB):

 fetch address=192.168.83.23 src-path="routeros-mipsbe-5.25.n
pk" user=root password=m1kr0t1k dst-path="routeros-mipsbe-5.25.ori" upload=yes mode
=ftp

Who is online

Users browsing this forum: No registered users and 7 guests