Community discussions

MikroTik App
 
User avatar
jarus10
just joined
Topic Author
Posts: 1
Joined: Tue Sep 05, 2006 1:19 am
Location: PL

How to upload a script using FTP?

Tue Sep 05, 2006 3:33 am

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).
 
User avatar
raivis-v
Frequent Visitor
Frequent Visitor
Posts: 55
Joined: Thu Jul 14, 2005 10:21 am
Location: Latvia, Riga

Re: How to upload a script using FTP?

Mon Sep 18, 2006 2:37 pm

Try this one:
system scheduler add name=scheduler_name on-event={import script_name}
 
pjulian
Member Candidate
Member Candidate
Posts: 267
Joined: Mon May 31, 2004 12:16 pm
Location: Sydney, Australia

Mon Sep 18, 2006 4:51 pm

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
 
cdavis
newbie
Posts: 38
Joined: Sun Aug 01, 2004 3:42 am

Sun Oct 29, 2006 3:01 pm

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.
 
pjulian
Member Candidate
Member Candidate
Posts: 267
Joined: Mon May 31, 2004 12:16 pm
Location: Sydney, Australia

Sun Oct 29, 2006 11:40 pm

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
 
cdavis
newbie
Posts: 38
Joined: Sun Aug 01, 2004 3:42 am

Mon Oct 30, 2006 5:42 pm

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.
 
pjulian
Member Candidate
Member Candidate
Posts: 267
Joined: Mon May 31, 2004 12:16 pm
Location: Sydney, Australia

Tue Oct 31, 2006 12:26 am

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
 
stafross
just joined
Posts: 13
Joined: Tue May 09, 2006 7:04 pm

Wed Apr 18, 2007 5:10 pm

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.
 
dada
Member Candidate
Member Candidate
Posts: 245
Joined: Tue Feb 21, 2006 1:44 pm

Thu Apr 19, 2007 4:07 pm

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.
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
 
stafross
just joined
Posts: 13
Joined: Tue May 09, 2006 7:04 pm

Thu Apr 19, 2007 5:45 pm

It executes correctly if i do it manualy

Who is online

Users browsing this forum: No registered users and 30 guests