Community discussions

MikroTik App
 
prasong
just joined
Topic Author
Posts: 2
Joined: Wed Jun 05, 2013 8:50 am

dialy upload multiple logging file to FTP Server.

Thu Jul 31, 2014 8:26 am

hi there
i try to upload name *LOGGING* as scripting below
----------------------------
foreach x in=[/file find] do={:if ([[:find [/file get $x name] "LOGGING"]]!="nil") do={tool fetch address=xxx.xxx.xxx.xxx port=21 src-path="$i" user=abc mode=ftp password=xyz dst-path="\$i" upload=yes}}
-----------------------------
seem system can not FTP interner ID? it's has 3 files in system as output below.
-----------------------------
foreach x in=[/file find] do={:if ([[:find [/file get $x name] "LOGGING"]]!="nil") do={put $x}}
*1f0101f4
*1f0103f0
*1f010406

Please advise how to upload multiple logging file (LOGGING.0.txt , LOGGING.1.txt, ..... LOGGING.x.txt)
thank for advanced
Prasong P.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 2954
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

Re: dialy upload multiple logging file to FTP Server.

Thu Jul 31, 2014 10:57 am

First of all, I make the script easy readable:
foreach x in=[/file find] do={
 :if ([[:find [/file get $x name] "LOGGING"]]!="nil") do={
 tool fetch address=xxx.xxx.xxx.xxx port=21 src-path="$i" user=abc mode=ftp password=xyz dst-path="\$i" upload=yes
 }
}
Second I fix all the errors on syntax:
:foreach x in=[/file find] do={
 :if ([:find [/file get $x value-name=name] "LOGGING"] != "nil") do={
  /tool fetch mode=ftp address=xxx.xxx.xxx.xxx port=21 user=abc password=xyz upload=yes src-path=$i dst-path=$i keep-result=no;
 };
};
And now I make all more simpler:
:foreach filefound in=[/file find where name~"LOGGING"] do={
 :local filename value=[/file get $filefound value-name=name];
 /tool fetch mode=ftp address=xxx.xxx.xxx.xxx port=21 user=abc password=xyz upload=yes src-path=$filename dst-path=$filename keep-result=no;
 /delay delay-time=10s;
};
Increase delay-time if the file are bigger and the upload is slower.
I'm Italian, not English. Sorry for my imperfect grammar.

Who is online

Users browsing this forum: shahani and 19 guests