Page 1 of 1
FTP File transfer from Mikrotik to non Mikrotik FTP Server
Posted: Tue Jan 26, 2010 9:25 am
by synapsis
Hi there
I want to transfer a data file that some other scripts I have written create, from a Mikrotik Router to a non Mikrotik FTP Server using a script and scheduling it to run on a periodic basis or to run when certain conditions are satisfied. In essence I want the Mikrotik Router to act as an FTP Client, not an FTP Server.
I've played around with fetch and I haven't been able to get it working in this manner and the documentation in the manual is very lacking in detail so I don't know if this is possible or not.
(BTW, yes technically I could write a script that runs on the FTP Server and pulls the file from the Mikrotik Router, but this would only satisfy the periodic transfer requirement. It would not satisfy my requirement to push the file up to a server when certain conditions are met.)
Anyone have any thoughts? Can fetch operate in this manner or should I use a different approach?
R
Re: FTP File transfer from Mikrotik to non Mikrotik FTP Server
Posted: Tue Jan 26, 2010 9:50 am
by mrz
Fetch can be used only to download files from servers, it cannot be used to send files.
You have to think of something else, send files by email or run script on ftp server to get files.
Re: FTP File transfer from Mikrotik to non Mikrotik FTP Server
Posted: Tue Jan 26, 2010 9:51 am
by dssmiktik
If you have an ssh client on your ftp server, you can execute a script on Mikrotik through ssh, then parse the results on your ftp server. If certain conditions are met, then ftp server would then "pull" the file(s) from the Mikrotik.
To autologin to the Mikrotik using DSA keys, see:
http://wiki.mikrotik.com/wiki/Use_SSH_t ... y_login%29
Ex. On your ftp server, create a bash script:
This is only an example to demonstrate the concept.
#!/bin/bash
MIKCMD=":if ([/interface ethernet get LAN disabled] = true) do={:put \"DISABLEDMESSAGE\"} else={:put \"ENABLEDMESSAGE\"}"
MIKRESULT="`ssh user:pass@router '$MIKCMD'`"
if [ "$MIKRESULT" == "DISABLEDMESSAGE" ]; then
# Any linux commands to execute if interface is disabled
echo "Interface is disabled"
fi
if [ "$MIKRESULT" == "ENABLEDMESSAGE" ]; then
# Any linux commands to execute if interface is enabled
echo "Interface is enabled"
fi
Then, you can set this script to run via cron on your ftp server.
Re: FTP File transfer from Mikrotik to non Mikrotik FTP Serv
Posted: Mon Feb 28, 2011 1:35 pm
by sw0rdf1sh
Actually you can use fetch toll to send files in a workaround.
Fetch as mentioned is only used to download.But if you download a php page with the correct values in the title you can send these values to a mysql database or even store it in text files or even store graphs on a chmod 777 location (where the php page is stored).
Haven't tried to send a file yet.I think it's possible but I am lacking the php knowledge. I would like to send the png's of the graphs every 2 or 4 hours.Right now I am only sending some values as mac addresses or users online...
Re: FTP File transfer from Mikrotik to non Mikrotik FTP Serv
Posted: Tue Mar 01, 2011 1:34 am
by dssmiktik
I guess you could also use fetch in GET mode to trigger a remote php script to ftp files from the router.
I haven't tested this, but if you run php on the back-end, it should be able to ftp into the router.
Ex.
/tool fetch address=a.b.c.d src-path="/mikchanged.php?action=pullgraphs" dst-path="pullgraphs.txt" mode=http
Then have the php script return a code, which you can now parse pullgraphs.txt from a RouterOS script to determine status.
Hope this makes sense. I like this approach as it still pulls, but in special cases can also be triggered. In the end, you have a central server to pull files/execute commands. The router in this case is will just trigger a pull immediately if required.
Re: FTP File transfer from Mikrotik to non Mikrotik FTP Serv
Posted: Tue Mar 01, 2011 9:43 am
by mrz
Actually starting from one of the v5RC versions fetch can be used to upload files.
http://wiki.mikrotik.com/wiki/Manual:To ... h#Examples
Re: FTP File transfer from Mikrotik to non Mikrotik FTP Server
Posted: Fri May 04, 2018 4:53 am
by xr4t3d85
Hi there
I want to transfer a data file that some other scripts I have written create, from a Mikrotik Router to a non Mikrotik FTP Server using a script and scheduling it to run on a periodic basis or to run when certain conditions are satisfied. In essence I want the Mikrotik Router to act as an FTP Client, not an FTP Server.
I've played around with fetch and I haven't been able to get it working in this manner and the documentation in the manual is very lacking in detail so I don't know if this is possible or not.
(BTW, yes technically I could write a script that runs on the FTP Server and pulls the file from the Mikrotik Router, but this would only satisfy the periodic transfer requirement. It would not satisfy my requirement to push the file up to a server when certain conditions are met.)
Anyone have any thoughts? Can fetch operate in this manner or should I use a different approach?
R
I was able to successfully get the Mikrotik router to successfully upload a configuration file to an FTP Server. Start with the /tool fetch command below and you can begin molding the script you need to complete your task. The script I have built now exports the running config, uploads to FTP Server and then deletes the config copy locally.
# Version info #
RouterBoard Firmware: 6.42
Mikrotik Version: 6.42
/tool fetch address=10.0.0.10 src-path=Filename.rsc user=admin mode=ftp password=Y0rP@55word! dst-path="/Folder01/Filename.rsc" upload=yes;
Re: FTP File transfer from Mikrotik to non Mikrotik FTP Server
Posted: Tue May 07, 2019 1:32 pm
by behzad24
hi
I have a Mikrotik sq Radio that has been disabled by its jumper reset, and also i forgotten password. any solution ?, and how i can reset or reinstalling (netinstall) it?
best regards,
behzad