Manual:Tools/Fetch: Difference between revisions

From MikroTik Wiki
Jump to navigation Jump to search
No edit summary
Line 59: Line 59:
<pre>address=wiki.mikrotik.com host=forum.mikrotik.com</pre>
<pre>address=wiki.mikrotik.com host=forum.mikrotik.com</pre>
In this example the resolved ip address is the same (66.228.113.27), but hosts are different.
In this example the resolved ip address is the same (66.228.113.27), but hosts are different.
}}
{{Mr-arg-table
|arg=http-method
|type={{!}}delete{{!}}get{{!}}post{{!}}put
|default=get
|desc=the HTTP method to use
}}
{{Mr-arg-table
|arg=http-data
|type=string
|default=
|desc=the data, that is going to be send, when using PUT or POST methods
}}
{{Mr-arg-table
|arg=http-content-type
|type=string
|default=application/x-www-form-urlencoded
|desc=the [https://en.wikipedia.org/wiki/Media_type#Common_examples MIME type] of the data you are going to send via POST/GET.
}}
}}


Line 116: Line 137:
|desc=User name, which is needed for authentication to the remote device.
|desc=User name, which is needed for authentication to the remote device.
}}
}}


==Examples==
==Examples==

Revision as of 15:21, 21 February 2018

Version.png

Applies to RouterOS: v3, v4 +

Summary

Sub-menu: /tool fetch
Standards:


Fetch is one of the console tools in Mikrotik RouterOS. It is used to copy files from any network device to a Mikrotik router via HTTP or FTP.


In latest v5 versions it is possible also to upload files to remote locations.


Fetch now supports HTTPS protocol. By default no certificate checks are made, but setting check-certificate to yes enables trust chain validation from local certificate store.

Properties

Property Description
address (string; Default: ) IP address of the device to copy file from.
ascii (yes | no; Default: no)
check-certificate (yes | no; Default: no) Enables trust chain validation from local certificate store.
dst-path (string; Default: ) Destination filename and path
host (string; Default: ) Domain name or virtual domain name (if used on web-site, from which you want to copy information). For example,
address=wiki.mikrotik.com host=forum.mikrotik.com
In this example the resolved ip address is the same (66.228.113.27), but hosts are different.
http-method (|delete|get|post|put; Default: get) the HTTP method to use
http-data (string; Default: ) the data, that is going to be send, when using PUT or POST methods
http-content-type (string; Default: application/x-www-form-urlencoded) the MIME type of the data you are going to send via POST/GET.
keep-result (yes | no; Default: yes) If yes, creates an input file.
mode (ftp|http|tftp {!} https; Default: http) Choose the protocol of connection - http, https , ftp or tftp.
password (string; Default: anonymous) Password, which is needed for authentication to the remote device.
port (integer; Default: ) Connection port.
src-path (string; Default: ) Title of the remote file you need to copy.
upload (yes | no; Default: no) If enabled then fetch will be used to upload file to remote server. Requires src-path and dst-path parameters to be set.
url (string; Default: ) URL pointing to file. Can be used instead of address and src-path parameters.
user (string; Default: anonymous) User name, which is needed for authentication to the remote device.

Examples

The following example shows how to copy the file with filename "conf.rsc" from device with ip address 192.168.88.2 by FTP protocol and save it as file with filename "123.rsc". User and password are needed to login into the device.

[admin@mt-test] /tool> fetch address=192.168.88.2 src-path=conf.rsc \
user=admin mode=ftp password=123 dst-path=123.rsc port=21 \
host="" keep-result=yes

Example to upload file to other router:

[admin@mt-test] /tool> fetch address=192.168.88.2 src-path=conf.rsc \
user=admin mode=ftp password=123 dst-path=123.rsc upload=yes


Another example that demonstrates the usage of url property.

[admin@test_host] /> /tool fetch url="http://www.mikrotik.com/img/netaddresses2.pdf" mode=http 
  status: finished

[admin@test_host] /> /file print 
 # NAME                     TYPE                  SIZE                 CREATION-TIME       
 ...
 5 netaddresses2.pdf        .pdf file             11547                jun/01/2010 11:59:51


[ Top | Back to Content ]