I have a few MT, and I’d like to upload one script to each MT. There is no problem with uploading, but with executing this script. It exist only in direrectory FILES, but not on the list with scripts. What should I do to run this script on MT. Of course I’ll do that using scheduler, but this tool see only scripts from list of scripts, not from directory FILE, where I’ve loaded it by FTP. How can I change it?
If I’m doing something wrong - what is a right solution to run some script which exist on my computer on a 5 MT (ex. an every hour).
Try this one:
system scheduler add name=scheduler_name on-event={import script_name}
Your script must have an extension of .rsc and to run it, just upload it to your router using FTP (binary mode) and then use the scheduler to run the script by using the command “/import scriptname.rsc”
I do this all the time to dynamically update firewall rules and it works a treat.
Some commands don’t work properly when run from inside a script although they work fine from a terminal session, this seems to be something to do with the environment difference between the two.
Regards
Paul
Can you elaborate on how you do this to update fw rules? I want to use this method to udpate queue speeds for people depending on what they are paying for.
I always upload to the default location (FILES) and then use the scheduler to run the scripts and have never had an issue. They don’t actually appear as scripts because they are files with script commands in them. Only a script they you have created within MT will appear in the script window. You must make a script within MT that then imports the script you have uploaded to the machine, then get the scheduler to run that small import script and you should be right.
For example, make a script called “import_scripts”, then upload your scripts, say “script1.rsc”, “script2.rsc”. Then inside your “import_scripts” script, add the commands “/import script1.rsc” and “/import script2.rsc” and then set the scheduler to run the “import_scripts” script however often you like. Obviously it will continue to run those scripts, so if you want them to do anything different then you need to replace the scripts regularly depending on what you want to acheive.
Regards
Paul
Could you post an example of the script1.rsc and import_scripts. It seems like it makes sense, but I would like to see an example to hammer it home.
The import script is exactly as I wrote in my previous post, just the import command with the script name, really simple.
Here is an example of a script that I import to run blacklists and whitelists:
/ip firewall rule blacklist
:foreach i in=[/ip firewall rule blacklist find] do=[/ip firewall rule blacklist remove $i]
Add whitelist rules
add protocol=tcp content=good action=return
Add blacklist rules
add protocol=tcp content=whatever action=reject log=yes
add protocol=tcp content=something action=reject log=yes
Add return
add in-interface=dsl action=return
You just simply enter commands as you would in the command line interface, but beware as some don't work from within scripts.
Regards
Paul
I have come across a strange one.
I have a script file that imports correctly from the terminal with:
/ import CPEsetup.rsc
But if I run it from a schedule as above it only executes to the line:
/ ppp aaa
set use-radius=yes accounting=yes interim-update=3m
If I remove this line is executes correctly.
If anyone has a idee what can cause this please respond.
What happen if you run the lines manually? I am not using PPP so I know nothing about the parameters for radius used in MT
It executes correctly if i do it manualy