Community discussions

MikroTik App
 
electravis
Member Candidate
Member Candidate
Topic Author
Posts: 274
Joined: Tue Jan 26, 2010 12:06 am

transfer file to mikrotik and run as script

Tue Apr 26, 2011 5:08 pm

I am not sure if this is possible or not but I am trying to do the following.
I have a file on an ftp server that has scripts in it. I want the mikrotik to download this file and then execute the scripts within the file.
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: transfer file to mikrotik and run as script

Tue Apr 26, 2011 5:11 pm

Write a script that uses "/tool fetch" to download the file (http://wiki.mikrotik.com/wiki/Manual:Tools/Fetch) and set a known file name via the dst-path parameter, and then as a next step runs "/import file-name=nameOfFileYouJustfetched".

Also, just FYI, if you upload (via push, not a download triggered by the OS) a file named whatever.auto.rsc it will get executed once you have uploaded it. Just in case that method works better for you.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: transfer file to mikrotik and run as script

Wed Apr 27, 2011 10:27 am

better use auto.rsc feature - using ftp you can upload file called <something>.auto.rsc

script file will be automatically executed and log file for that will be saved on the router.
 
reverged
Member Candidate
Member Candidate
Posts: 270
Joined: Thu Nov 12, 2009 8:30 am

Re: transfer file to mikrotik and run as script

Sun May 22, 2011 7:56 am

better use aut.rsc feature - using ftp you can upload file called <something>.auto.rsc

script file will be automatically executed and log file for that will be saved on the router.
It might be worth noting that the script does not execute immediately upon upload.
It executes when the ftp connection is closed. A not so subtle detail.
This might be important if you are expecting something to happen and you leave the connection open.....like I was and I did.

This is a useful feature. And a great way to push changes.
 
brainy
Member Candidate
Member Candidate
Posts: 155
Joined: Fri Sep 29, 2006 3:08 pm
Location: Unterschleissheim, Germany
Contact:

Re: transfer file to mikrotik and run as script

Fri Sep 02, 2011 3:17 pm

We are uploading the auto.rsc scripts via ftp ... but very often the file is not executed, instead of that the log shows "ppp script error: input does not match any value of file-name"

If we upload it again it is executed.. someone else having this problem also?
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: transfer file to mikrotik and run as script

Mon Sep 05, 2011 11:44 am

what settings are you trying to push? maybe there is some problem with ppp interface missing/appearing?
 
brainy
Member Candidate
Member Candidate
Posts: 155
Joined: Fri Sep 29, 2006 3:08 pm
Location: Unterschleissheim, Germany
Contact:

Re: transfer file to mikrotik and run as script

Mon Sep 05, 2011 12:27 pm

Janis, the interesting thing is that it doesnt matter what script we upload... even when i upload a script that only does "/system reset-configuration" it shows that error.
 
User avatar
skot
Long time Member
Long time Member
Posts: 584
Joined: Wed Nov 30, 2011 3:05 am

Re: transfer file to mikrotik and run as script

Thu May 24, 2012 1:56 am

We are uploading the auto.rsc scripts via ftp ... but very often the file is not executed, instead of that the log shows "ppp script error: input does not match any value of file-name"

If we upload it again it is executed.. someone else having this problem also?
Yes, I also have this problem, posted problem here: http://forum.mikrotik.com/viewtopic.php?f=9&t=62261
 
angboontiong
Forum Guru
Forum Guru
Posts: 1136
Joined: Fri Jan 16, 2009 9:59 am

Re: transfer file to mikrotik and run as script

Thu May 24, 2012 5:41 pm

what i do is...
1) a scheduler (24 hours interval)to fetch the file (command to run) from the server call xxx.txt, then...
2) delay 5s
3) translate the file content to the "system script" like call "auto-run", then
4) delay 5s
5) run the "auto-run" and once complete it will delete the "auto-run"

whatever new thing to add or new command to run, all the routerboard with this scheduler will auto update when it meet the scheduler time.
 
EarthStation
Frequent Visitor
Frequent Visitor
Posts: 72
Joined: Mon May 24, 2010 4:06 pm

Re: transfer file to mikrotik and run as script

Fri May 25, 2012 2:26 pm

I use this file to roll out CPE changes (not ROS upgrades).
{
:global ftpserver
:global usrnme
:global passwd
:global pckgname

:set pckgname ("upgrade.rsc")
:set ftpserver "10.254.253.254"
:set usrnme "admin"
:set passwd "abcxyz123"

:if ([:len [/file find name="upgrade"]] = 0) do={:log error "Downloading Upgrade File - $pckgname";/tool fetch address="$ftpserver" src-path="$pckgname" user="$usrnme" password="$passwd" mode=ftp;/import upgrade.rsc} else={:log error "No Upgrade File Found";}
}
This script can be called by a scheduler, or a netwatch routine that looks for an IP that we turn on and off when we want to trigger the script.

Regards
Brian
Zimbabwe
 
tiran
Frequent Visitor
Frequent Visitor
Posts: 50
Joined: Fri Aug 07, 2015 2:53 pm

Re: transfer file to mikrotik and run as script

Wed Nov 20, 2019 1:30 pm

how can i set ftp server path = 192.168.88.1/disk1

Who is online

Users browsing this forum: No registered users and 19 guests