Hi,
I want to move a file using the /file commands, however I cant see any way to do this.
can anyone help?
Hi,
I want to move a file using the /file commands, however I cant see any way to do this.
can anyone help?
move a file where? no, probably not possible.
Hi,
sorry to another folder.
you can do that only with winbox drag-and-drop
disapointing.
would be good to have in scripting!
please give an example when this would be useful?
Hi,
we are writing an automation system where we want to update the hotspot files with new ones, so we fetch them, then we would want to move them to a new folder.
I know we can do this via FTP the other way around, however I would prefer to do it via scripting.
Also would be good to be able to name the result of the “/tool fetch”, we are sending alot of data, (or trying too) but the special characters are naming the files wrong and breaking it.
great, that would really be appreciated.
We have about 950 mikrotik boards in the field at the moment, would be nice to have a script that can do everything automatically, will allow me to get a holiday at the end of the year ![]()
Hey, can I put in my two cents worth.
I could also use file move, copy, delete, and rename commands and have them work across disk drives so you can move from flash to disk or disk to disk.
It would be real nice to be able to ftp with all the capabilities of ftp seen in Linux. Should be easy being MT router is embeded Linux. This could be used to put or get configurations, scripts, packet captures and OS upgrades, just to name a few. Image the power.
hotspotsolutions: why not make the initial login page a redirect page to a remote http server.. then you can host all content on there are redirect user to specific content based on the IP they are coming from, no need to login to each device to change.
If you could specify a root path destination with the fetch tool that would be really useful. We are having a similar problem and have several scripts used to send information to a destination on the web. Also the ability to copy/move files around on the Routerboard OS platform would be really useful. ![]()
It is possible to get a root shell on Mikrotik, and with a Busybox binary compiled with wget you can easily give the target path that you want your ‘fetched’ file to be saved, so it goes into the right place.
e.g. wget -O /var/pckg/hotspot/login.html http://11.22.33.44/login.html
Automating it requres that you have a busybox binary compiled with crond too, or you could write your own script to sleep for ages, do the wget, back to sleep etc.
Getting it to work requires physical access to the routerboard, and a fair amount of messing about though.
I just wish that the ‘fetch’ command had that same feature of wget.
OR,
you could just use a script to ‘fetch’ what you want, and then use mv to put it where you want it …
Moving a file would be extremely helpful as well. I can’t believe more people don’t bring it up, but when using /tool fetch to grab a dynamic cgi script contents, its a pain in the butt.
For example:
/tool fetch address=secure.myserver.com path=“cgi-bin/update.cgi?hw=00:11:22:33:44:55&fw=3.10&hn=acct2svc2&mode=ap” host=secure.myserver.com
The file becomes:
/file print
0 sysupdate.cgi?node=00:11:22:33:44:55&fw=3.10&hn=acct2svc2&mode=ap .10&hn=acct2svc2&mode=ap file 1405 jul/03/2008 01:52:32
a simple “outfile” parameter to ‘fetch’ would be grand.
I resolved all file problems with a copy. We can already remove files, and with an additional copy option, we can:
Here’s the code:
# Machine setup (one-time run)
# - Add a loopback interface (bridge with no interfaces linked to it)
/interface bridge
add admin-mac=00:00:00:00:00:00 ageing-time=5m arp=enabled auto-mac=yes \
comment="We use this loopback for the router to access itself. No interfac\
es should be assigned to it!" disabled=no forward-delay=15s l2mtu=65535 \
max-message-age=20s mtu=1500 name=loopback priority=0x8000 protocol-mode=\
none transmit-hold-count=6
/interface bridge settings
set use-ip-firewall=no use-ip-firewall-for-pppoe=no use-ip-firewall-for-vlan=\
no
# - Add a IP with subnet 255.255.255.255 (single-ip network)
/ip address add address=10.0.0.1/32 comment="Loopback for file copying" disabled=no \
interface=loopback network=10.0.0.1
# - Add global variables with the ftp user and password
:global ftpuid "self"
:global ftppwd "fdalsu90f3aopJIoIokidf0SI9"
# - Add a full-access user to do the copying (only allow address of router itself)
/user add address=127.0.0.1/32,10.0.0.1/32 comment="Loopback user" disabled=no \
group=full name=$ftpuid password=$ftppwd
# - Enable the ftp service (todo: use firewall filter to secure)
/ip service set ftp disabled=no port=21
########################################################
# Actual copying/moving script
/tool fetch mode="ftp" address="10.0.0.1" src-path="oldfilename.txt" dst-path="newfilename.txt" user=$ftpuid password=$ftppwd
# Optional: Remove the file, if you are moving or renaming
As you can see, I use a loopback interface with the IP 10.0.0.1. This allows you to block FTP on all other interfaces but still allow copying within the router.
If you have any questions, feedback or improvement, please let me know at my niels.bos@live.com e-mail address.
Cheers,
Niels