Community discussions

MikroTik App
 
christyler
just joined
Topic Author
Posts: 2
Joined: Mon Aug 25, 2008 1:42 pm

Copy all files from "files" to an FTP account

Wed May 04, 2011 4:25 am

Can anyone tell me how to do a script so i can copy the contents of "files" to and FTP server, Please ?
 
CyberT
Member Candidate
Member Candidate
Posts: 172
Joined: Tue Feb 01, 2011 1:39 pm
Location: Johannesburg, South Africa
Contact:

Re: Copy all files from "files" to an FTP account

Wed May 04, 2011 1:17 pm

Do you want to do an FTP put command from the Tik?


I would recommend the easiest way is to get a FTP pull application or a FTP client that can frequently check the device for changes?
 
bburley
Frequent Visitor
Frequent Visitor
Posts: 80
Joined: Thu Nov 18, 2010 7:22 am
Location: Alberta, Canada

Re: Copy all files from "files" to an FTP account

Thu May 05, 2011 8:33 am

I ran into an intermittent problem with a scheduled ftp client uploading files to RB1100's. It sometimes fails to connect or it will connect and then reject the upload, and/or other wierdness. The automation is done with a "dumb" batch file and auto-generated text file for the ftp commands.

This method is a problem because it is unable to react to any errors. I looked around and found "WinSCP" which is an open source scriptable ftp client. I haven't had time to try it yet, but it might solve both of our problems.
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Copy all files from "files" to an FTP account

Thu May 05, 2011 4:58 pm

As long as all files are in the root, something like this should work:
:local FTPserverAddress "192.168.88.2";
:local FTPuser "myUser";
:local FTPpass "myPass";
:foreach FILE in=[/file find] do={
  :local name [/file get $FILE name];
  /tool fetch address="$FTPserverAddress" src-path="$name" user="$FTPuser" mode=ftp password="$FTPpass" upload=yes;
}
http://wiki.mikrotik.com/wiki/Manual:To ... h#Examples
As far as I know you cannot create directories on the FTP server, so copying directory structures via push is impossible.