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:
Using batch file to automate ftp login / commands.
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.
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.
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