I'm newbie to this forum, but I have some experience with MikroTik devices and programming in several languages. I know that many of you use Notepad++ as the RouterOS script editor. Therefore, I am sharing a description of the my solution that allows you to download and upload the source code directly from/to the RouterOS device. Just by one click from the Run menu in the Notepad++ editor.
Everything was written and tested on Windows 10, but it should also work properly on Windows 11. If anyone has Win11, please test it.
Prerequisites:
- Installed Notepad++ (N++), of course . I used latest version 8.6.4 (64bit)
- Enabled RouterOS script syntax highlighting in N++. There are several threads on this forum regarding this issue. But the easiest way is to use the UDL (User Defined Language) repository, which is available in the "Language->Notepad++ User Defined Language collection" menu. Currently there is “RouterOS Script - NieL™”
- Active REST API on the RouterOS device.
- Installed jq utility. It's a small but powerful command line JSON processor. Can be downloaded for free from https://jqlang.github.io/jq/. The exe file should be placed in a directory belonging to the PATH of the Windows system or user. I used latest 1.7.1 compiled for Windows 64bit.
Installation steps:
- Download the ROSintegration_v1.zip file attached below and extract the contents to the directory where Notepad++ is located (notepad++.exe). Most often it is c:\Program files\Notepad++. The ZIP archive contains 3 files:
- ROSlib.cmd – utility functions for other two scripts
- ROSdownload.cmd - script that downloads code from the RouterOS device into the N++ document
- ROSupload.cmd - script that uploads code from the N++ document into the RouterOS device
- Open to edit (using N++) file ROSlib.cmd, find line contains set jqBinary=jq-windows-amd64.exe and change it value to name or path to your jq executable file
Code: Select all:getJqBinary RtnVar rem Name or full path to jq utility executable rem see https://jqlang.github.io/jq/ set jqBinary=jq-windows-amd64.exe set "%~1=%jqBinary%" exit /B
- Open to edit (using N++) file shortcuts.xml, located in the same directory as the notepad++.exe file. Create backup copy of this file before…
- Paste the code below between the tags <UserDefinedCommands> </UserDefinedCommands> of the shortcuts.xml. You must replace url_to_your_router_os_api and api_username:user_password with your own values. If you want, modify the "name" attribute.
Code: Select all<Command name="Download RouterOS script" Ctrl="no" Alt="yes" Shift="no" Key="34"> "$(NPP_DIRECTORY)\ROSdownload.cmd" "url_to_your_router_os_api" "api_username:user_password" "$(FULL_CURRENT_PATH)" </Command> <Command name="Upload RouterOS script" Ctrl="no" Alt="yes" Shift="no" Key="33"> "$(NPP_DIRECTORY)\ROSupload.cmd" "url_to_your_router_os_ap" "api_username:user_password" "$(FULL_CURRENT_PATH)" </Command>
- Save shortcuts.xml file and restart Notepad++
- You should now see the new commands in the Run N++ menu
- In Notepad++, create a new document whose name will be identical to the name of the script in the RouterOS device. For example, if the name of the script on the router is wanFailover, name the new document wanFailover.rsc
- Run command “Run->Download RouterOS script” or press Alt+Page Down. You should see source code inside document.
- Make any changes in Notepad++ document. For example add new comment. Save document and “Run->Upload RouterOS script” or press Alt+Page Up
- Open WinBox and check source code of your script. You should see modifications made in Notepad++.
You can change everything, but please keep the CC BY license information contained in the ROS*.cmd files- and remember, this is a version beta, tested and used only be me so far...
Notepad++ & RouterOS Scripts integration © 2024 by miku (forum.mikrotik.com) is licensed under CC BY