Community discussions

MikroTik App
 
sejtam
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 67
Joined: Sun Dec 14, 2014 4:23 pm

how to upload a script for storage in the script repository

Sun Jan 04, 2015 7:46 am

There are several pages with sample script. eg like this:
/system backup save name=email_backup
/tool e-mail send file=email_backup.backup to="me@test.com" body="See attached file" \
   subject="$[/system identity get name] $[/system clock get time] $[/system clock get date] Backup")
It seems one cannot just put that into a file, upload it and then
/import filename
it, as that just tries to execute that code exactly once.

It seems I have to excapsulate the give code with the actual 'script add' command IN THE FILE:
/system script add name="sched_backup_email" source={
/export file=current_config hide-sensitive
/tool e-mail send file=current_config.rsc to="admin@koerber.org" body="See attached file" \
   subject="$[/system identity get name] $[/system clock get time] $[/system clock get date] configuration export"
}
I found no other way to turn the scriptfile (without script add) into a script, nor does it seem possible to just
tell the scheduler to run a file.

Am I missing anything?
 
User avatar
jacekes
Member Candidate
Member Candidate
Posts: 167
Joined: Tue Aug 30, 2011 9:34 am
Location: Poznan, Poland
Contact:

Re: how to upload a script for storage in the script reposit

Sun Jan 04, 2015 12:23 pm

Encapsulating it into a "/system script add" command is the right way. It's also worth remembering you might need to escape special characters in the script source.