Hi, i have some trouble for understanding how correctly works a routeros scripting funcion.
I have this small piece of code that i want to implement in some of my existing scripts.
do {
global aIP "10.50.0.191"
global aID "Test"
global logftp "ftp/$aID_ftp.log"
global UPL do={/tool fetch upload=yes url="sftp://$aIP/$1" src-path="$2" user="admin-ssh" keep-result=no;}
execute file=$logftp script=[$UPL dude_rsa.pub server.pub]
}
I dont understand why if i paste this on a terminal it work perfectly:
status: finished
uploaded: 0KiB
total: 0KiB
duration: 1s
If i paste this on routeros script and try to run it i give this error:
You forgot the “:” everywhere,
you forgot to declare global variables (used) inside the script,
you used the “;” unnecessarily
“do” uselessly say nothing to… do
Hi, now is working but the created ftp log file is empty, i would use it for search if inside this file there is the word "finished":
local logres [/file get [find name="$logftp.txt"] contents]
:if ($logres~"finished") do={
It’s obvious, the result of the fetch is not one “script” that you can provide to execute…
the rapid soluction for this case is this, but is not longer “a function”…
{
:local aIP “10.50.0.191”
:local aID “Test”
:local logftp “ftp/$aID_ftp.log”
Meanwhile, thank you very much for your support, it would have been useful to have a function to call within the script to be able to reuse it in several parts of the program, but if there is no way I will use your method, in the end I just want the script to be reliable.