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?
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.
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.
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.
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…
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.
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.
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?