Hello … I would like to have a file with multiple lines, where each line would contain a name, following the example:
NAME1.txt
NAME2.txt
NAME3.txt
…
How do I make a loop to read the file and download via FTP the files contained within it?
Hello … I would like to have a file with multiple lines, where each line would contain a name, following the example:
NAME1.txt
NAME2.txt
NAME3.txt
…
How do I make a loop to read the file and download via FTP the files contained within it?
I use something like this. It loops through the file line by line and saves the line as a variable. Then you can use the variable however you want. To download via ftp, use fetch:
:local content [/file get [/file find name=file.txt] contents];
:local contentLen [:len $content];
:local lineEnd 0;
:local line “”;
:local lastEnd 0;
:while ($lineEnd < $contentLen) do={
:set lineEnd [:find $content "\n" $lastEnd];
:if ([:len $lineEnd] = 0) do={
:set lineEnd $contentLen;
}
:set line [:pick $content $lastEnd $lineEnd];
:set lastEnd ($lineEnd + 1);
:if ($line != "\r") do={
/tool fetch address=192.168.1.1 src-path=$line user=USER mode=ftp password=PASS port=21;
}
}