Fetch upload auto.rsc between routers not executing

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?

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

Thanks!

Simple fix was to just add a blank line at the end of the script. Now its working as expected.

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.

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.

The “blank line” idea did not work for me.

I upgraded routers to 5.22, still same problem. Submitting this as a bug…

I confirm this bug for RB750 with 5.24 RouterOS.
Please please MT, fix it!

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.
: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.
@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

Blank line at the end of file and ftp pre-removing .auto.rsc made my script to autorun again :slight_smile:

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?

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.