Community discussions

MikroTik App
 
User avatar
LucZWFM
Member Candidate
Member Candidate
Topic Author
Posts: 130
Joined: Tue Dec 26, 2017 10:47 pm
Location: Bergen op Zoom, The Netherlands

Export / Import Scripts & Schedulers ?

Sat Sep 15, 2018 2:35 pm

Is it possible to export scripts and schedulers and then import them in another device?
Now I have to copy/paste all the time so an export / import way would be very welcome.
 
jarda
Forum Guru
Forum Guru
Posts: 7756
Joined: Mon Oct 22, 2012 4:46 pm

Re: Export / Import Scripts & Schedulers ?

Sat Sep 15, 2018 3:48 pm

Yes. Use export and import commands.
 
User avatar
LucZWFM
Member Candidate
Member Candidate
Topic Author
Posts: 130
Joined: Tue Dec 26, 2017 10:47 pm
Location: Bergen op Zoom, The Netherlands

Re: Export / Import Scripts & Schedulers ?

Sat Sep 15, 2018 5:33 pm

Yes. Use export and import commands.

I understand that, but I don't have any clu of them...
Syntax example please?
 
sindy
Forum Guru
Forum Guru
Posts: 10206
Joined: Mon Dec 04, 2017 9:19 pm

Re: Export / Import Scripts & Schedulers ?

Sat Sep 15, 2018 5:50 pm

/system script export file=all-my-scripts

import file-name=all-my-scripts

Same with /system scheduler or any other part of the configuration.
 
User avatar
LucZWFM
Member Candidate
Member Candidate
Topic Author
Posts: 130
Joined: Tue Dec 26, 2017 10:47 pm
Location: Bergen op Zoom, The Netherlands

Re: Export / Import Scripts & Schedulers ?

Sat Sep 15, 2018 5:55 pm

/system script export file=all-my-scripts

import file-name=all-my-scripts

Same with /system scheduler or any other part of the configuration.

Thanks!

Can it be done with only one script or schedule?
 
sindy
Forum Guru
Forum Guru
Posts: 10206
Joined: Mon Dec 04, 2017 9:19 pm

Re: Export / Import Scripts & Schedulers ?

Sat Sep 15, 2018 6:18 pm

You can use ssh to execute scripts on a remote Mikrotik, even using a key-based authentication and even from within a script, but unfortunately if you schedule such script, the ssh part of it fails (whoever can prove me wrong is welcome).

Besides, if you write a script to export your scripts and import them on another machine, it will be exported and imported along with them, so you'd probably want to do some text processing between the steps, for which Mikrotik's scripting is not the most convenient tool available.

So you may want to give a try to the automatic import functionality of RouterOS (using the /tool fetch command to upload a script file to a remote Mirotik using ftp) but the issue with text processing remains, and I am not sure whether scheduling a script which contains /tool fetch upload=yes won't have the same trouble like scheduling a script which contains /system ssh.
 
User avatar
LucZWFM
Member Candidate
Member Candidate
Topic Author
Posts: 130
Joined: Tue Dec 26, 2017 10:47 pm
Location: Bergen op Zoom, The Netherlands

Re: Export / Import Scripts & Schedulers ?

Sat Sep 15, 2018 6:34 pm

You can use ssh to execute scripts on a remote Mikrotik, even using a key-based authentication and even from within a script, but unfortunately if you schedule such script, the ssh part of it fails (whoever can prove me wrong is welcome).

Besides, if you write a script to export your scripts and import them on another machine, it will be exported and imported along with them, so you'd probably want to do some text processing between the steps, for which Mikrotik's scripting is not the most convenient tool available.

So you may want to give a try to the automatic import functionality of RouterOS (using the /tool fetch command to upload a script file to a remote Mirotik using ftp) but the issue with text processing remains, and I am not sure whether scheduling a script which contains /tool fetch upload=yes won't have the same trouble like scheduling a script which contains /system ssh.


Thanks again..

Maybe I didn't explain myself too well, what I mean is, can I export only one script or schedule?
 
sindy
Forum Guru
Forum Guru
Posts: 10206
Joined: Mon Dec 04, 2017 9:19 pm

Re: Export / Import Scripts & Schedulers ?

Sat Sep 15, 2018 7:02 pm

Yes, it was a misunderstanding :-) And no, you cannot export a single entry of a menu tree, text processing is your only workaround available if you limit yourself to RouterOS scripting (plus there is some maximum text file size which can be converted into a string variable and processed).

You can use /system script print where name=xxx file=some-file-name to selectively put just a single script into a file, but the format differs from the one of the /export so it is impossible to import such a file without text-processing it before.
 
User avatar
LucZWFM
Member Candidate
Member Candidate
Topic Author
Posts: 130
Joined: Tue Dec 26, 2017 10:47 pm
Location: Bergen op Zoom, The Netherlands

Re: Export / Import Scripts & Schedulers ?

Sat Sep 15, 2018 7:18 pm

Yes, it was a misunderstanding :-) And no, you cannot export a single entry of a menu tree, text processing is your only workaround available if you limit yourself to RouterOS scripting (plus there is some maximum text file size which can be converted into a string variable and processed).

You can use /system script print where name=xxx file=some-file-name to selectively put just a single script into a file, but the format differs from the one of the /export so it is impossible to import such a file without text-processing it before.

Thank you!

All clear now...

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 164 guests