Community discussions

MikroTik App
 
User avatar
skot
Long time Member
Long time Member
Topic Author
Posts: 584
Joined: Wed Nov 30, 2011 3:05 am

Fetch upload auto.rsc between routers not executing

Wed May 23, 2012 3:00 am

I'm seeing a problem when uploading *.auto.rsc scripts to a router with ftp.

When I manually upload auto.rsc file, it works fine.

However, when I automate the process, the file does not run automatically unless I upload it TWICE. First upload, the log file has a size of 0. Second upload the log shows output, and the script executes just fine.

So far, I have tried 2 methods:
1. Using batch file to automate ftp login / commands.
2. Using fetch ftp to upload script between routers:
/file print file=tmp
/file set tmp.txt contents="/log info testing"
/tool fetch address=192.168.0.25 src-path=tmp.txt user=admin mode=ftp upload=yes password=PASS dst-path=script.auto.rsc port=21;
With both methods, it's almost like the ftp session is closed BEFORE the file is available on the router, so the router can't find the file to execute. Uploading again, the file already exists, so it is available when the ftp session is closed, so the file is executed.

Any ideas?
 
webguyz
Frequent Visitor
Frequent Visitor
Posts: 52
Joined: Tue May 29, 2007 7:40 pm

Re: Fetch upload auto.rsc between routers not executing

Wed Jul 25, 2012 9:53 am

Any resolution to this? Running into the same problem with ftp. Have to upload it twice.

Thanks!
 
webguyz
Frequent Visitor
Frequent Visitor
Posts: 52
Joined: Tue May 29, 2007 7:40 pm

Re: Fetch upload auto.rsc between routers not executing

Wed Jul 25, 2012 5:01 pm

Simple fix was to just add a blank line at the end of the script. Now its working as expected.
 
bestefan
just joined
Posts: 17
Joined: Fri Nov 21, 2008 9:23 am

Re: Fetch upload auto.rsc between routers not executing

Wed Aug 08, 2012 9:22 am

Hi, I have the same problem.

I have uploaded exactly the same file.auto.rsc (with blank line at the end) to two different router (all are v.5.19).
In one execute the script fine, and log created successfull, in the other one the upload is OK, but the script did not execute, and the file.auto.log is empty.
 
User avatar
DaxStox
newbie
Posts: 41
Joined: Thu Aug 30, 2012 6:59 pm

Re: Fetch upload auto.rsc between routers not executing

Fri Aug 31, 2012 12:06 pm

I test my own "file.auto.rsc" and it works always after a reboot. I think the file works only the first time after e reboot.

I hope this is useful.

Bye.
 
User avatar
skot
Long time Member
Long time Member
Topic Author
Posts: 584
Joined: Wed Nov 30, 2011 3:05 am

Re: Fetch upload auto.rsc between routers not executing

Tue Dec 11, 2012 8:47 pm

The "blank line" idea did not work for me.

I upgraded routers to 5.22, still same problem. Submitting this as a bug...
 
Ansy
Frequent Visitor
Frequent Visitor
Posts: 72
Joined: Mon Oct 17, 2011 1:32 pm
Location: Russia
Contact:

Re: Fetch upload auto.rsc between routers not executing

Tue Mar 05, 2013 8:39 am

I confirm this bug for RB750 with 5.24 RouterOS.
Please please MT, fix it!
 
User avatar
skot
Long time Member
Long time Member
Topic Author
Posts: 584
Joined: Wed Nov 30, 2011 3:05 am

Re: Fetch upload auto.rsc between routers not executing

Sat Mar 09, 2013 1:47 am

It now appears to be working for me on v5.24 using a RB450G using the script above with one modification (unrelated to the topic). If tmp file does not exist on sending router, you have to add a delay before writing to the file. Otherwise, file does not exist yet, takes about a second for it to be available.

ros code

:if ([:len [/file find name="tmp.txt"]] = 0) do={
   /file print file=tmp
    :delay 2s;
}
/file set tmp.txt contents="/log info testing;:delay 2s;/file remove [find name~\"script.auto\"]"
/tool fetch address=192.168.0.25 src-path=tmp.txt user=admin mode=ftp upload=yes password=password dst-path=script.auto.rsc port=21;;
I also tested it using batch file with automated login... also working for me there.

batch code

@echo off

:: config
set user=admin
set pass=password
set ip=192.168.0.25

:: mikrotik script
echo /log info testing>script.auto.rsc
echo :delay 2s>>script.auto.rsc
echo /file remove [find name~"script.auto"]>>script.auto.rsc

:: ftp commands to upload script
echo user %user%> ftp.dat
echo %pass%>> ftp.dat
echo put script.auto.rsc>> ftp.dat
echo quit>> ftp.dat

:: upload script
ftp -n -s:ftp.dat %ip%> NUL

:: cleanup
del /q ftp.dat
del /q script.auto.rsc
 
Ansy
Frequent Visitor
Frequent Visitor
Posts: 72
Joined: Mon Oct 17, 2011 1:32 pm
Location: Russia
Contact:

Re: Fetch upload auto.rsc between routers not executing

Mon Mar 11, 2013 11:49 am

Blank line at the end of file and ftp pre-removing .auto.rsc made my script to autorun again :)
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Fetch upload auto.rsc between routers not executing

Mon Mar 11, 2013 4:07 pm

adding new-line at the end of aut.rsc script should be enough. At least in my tests it did execute.
 
User avatar
payday
Member Candidate
Member Candidate
Posts: 233
Joined: Thu Aug 16, 2012 11:05 pm

Re: Fetch upload auto.rsc between routers not executing

Mon Mar 11, 2013 6:05 pm

adding new-line at the end of aut.rsc script should be enough. At least in my tests it did execute.
Is it a official fix? Are you not going to fix the bug in firmware?
 
User avatar
skot
Long time Member
Long time Member
Topic Author
Posts: 584
Joined: Wed Nov 30, 2011 3:05 am

Re: Fetch upload auto.rsc between routers not executing

Mon Mar 11, 2013 10:05 pm

adding new-line at the end of aut.rsc script should be enough. At least in my tests it did execute.
Did not work for me.

Are you removing the auto.rsc file before each test?

If the auto.rsc exists on the router, and I upload it again, it executes normally. If it does not exist, and I upload it, it does not execute.

Who is online

Users browsing this forum: No registered users and 11 guests