Page 1 of 1

how to upload a script for storage in the script repository

Posted: Sun Jan 04, 2015 7:46 am
by sejtam
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?

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

Posted: Sun Jan 04, 2015 12:23 pm
by jacekes
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.