Community discussions

Search found 225 matches

by dasiu
Mon Aug 06, 2018 11:16 am
Forum: Scripting
Topic: Load functions from another script
Replies: 3
Views: 160

Re: Load functions from another script

You prefer to "load" it... where? Isn't "loading" to /system script environment, to the list of global variables/functions, enough? That's what I use - I have an .rsc file with "functions" I just run - and it loads the functions to globals. And other file to remove them. And in the main script I jus...
by dasiu
Mon Aug 06, 2018 11:12 am
Forum: Scripting
Topic: RouterOS SNMP Get
Replies: 5
Views: 248

Re: RouterOS SNMP Get

Hi! The is no "issue" with amount of data or anything... It's simple it's just NOT SUPPORTED yet :). I believe someone from MT staff said that they plan to introduce it later (can't remember, where), for now the snmp-get is just for user interaction, can't be scripted. I'm also waiting for it to be ...
by dasiu
Fri Aug 03, 2018 2:36 pm
Forum: The Dude
Topic: Unable to upgrade RouterOS
Replies: 2
Views: 156

Re: Unable to upgrade RouterOS

Is it a CHR with trial license which has expired?
by dasiu
Thu Aug 02, 2018 1:31 pm
Forum: Scripting
Topic: Load functions from another script
Replies: 3
Views: 160

Re: Load functions from another script

Yes, you can :). 1. Make the getKeyValue and setKeyValue functions :global instead of :local 2. Run the one script defining all those global functions on startup 3. In the beginning of your script using the functions put: :global getKeyValue; :global setKeyValue; So the globals are in the memory all...
by dasiu
Wed Aug 01, 2018 2:12 am
Forum: RouterBOARD hardware
Topic: REQUEST : New Switch for SOHO, upgrade to 10GB over copper
Replies: 7
Views: 559

Re: REQUEST : New Switch for SOHO, upgrade to 10GB over copper

Oh completely overlook, thanks for the hint. No, you didn't :). That CRS210 is discontinued , don't look at it :). As you mentioned you can get CSS 326 for half the price :). Also - you can get CRS326 for a bit less, having - besides the great switch and easy (bridge filter) VLAN configuration - te...
by dasiu
Tue Jul 31, 2018 11:13 am
Forum: Scripting
Topic: src-address
Replies: 3
Views: 146

Re: src-address

Use quotes :).
/ip fi man print where src-address="192.168.1.100"
edit: LOL, that timing :).
by dasiu
Thu Jul 26, 2018 12:19 am
Forum: Scripting
Topic: access to SSTP-Client Uptime
Replies: 3
Views: 151

Re: access to SSTP-Client Uptime

adding the 'as-value' incorporates each row of text into an array of text strings in memory indexed by the headings (left of the ':') and adding the ->"uptime" selects the row of the the array So: 1. Adding "as-value" presents the results of print (and also monitor) commands in the "array" form. To...
by dasiu
Wed Jul 25, 2018 9:20 pm
Forum: Scripting
Topic: Problem running script(s) [SOLVED]
Replies: 6
Views: 241

Re: Problem running script(s) [SOLVED]

Tried using local instead of global? Not ":global getDateTime" but ":local getDateTime"? If you have few scripts and they all have this function - they overwrite it and maybe it's causing the problem if they are doing it in the same time?
by dasiu
Wed Jul 25, 2018 9:18 pm
Forum: Scripting
Topic: cannot use ip firewall connection find [SOLVED]
Replies: 3
Views: 167

Re: cannot use ip firewall connection find [SOLVED]

It's correct, find works, you just don't SHOW the result of the find :). 1. dst-address in the entry is EQUAL TO "172.31.80.4:5060". Looking for "172.31.80.4" won't work. so it's either: find dst-address="172.31.80.4:5060" for this specific port, or: find dst-address~"172.31.80.4:" for all ports :)....
by dasiu
Wed Jul 25, 2018 9:11 pm
Forum: Scripting
Topic: access to SSTP-Client Uptime
Replies: 3
Views: 151

Re: access to SSTP-Client Uptime

:put ([/interface sstp-client monitor VPN-To-Host once as-value]->"uptime")
by dasiu
Mon Jul 23, 2018 3:09 am
Forum: Scripting
Topic: "/system resources" do miss "find", bug?
Replies: 3
Views: 138

Re: "/system resources" do miss "find", bug?

Hi, 1. Don't use "print as-value" if you don't need it. Learn how to use find and get. 2. Your example doesn't work, because there is no "dynamic" entry in system resources. Without "dynamic" it should work: log info message=[/system resource print as-value] 3. Please, look at this: log info message...
by dasiu
Sat Jul 21, 2018 12:13 pm
Forum: Scripting
Topic: Wifi Hotspot + cloud Management
Replies: 3
Views: 201

Re: Wifi Hotspot + cloud Management

Yes, 1. The usual approach is to set a RADIUS + MySQL + HTTP/PHP server that's controlling it, and set MikroTik hotspot to redirect to that page (with the login.html page HTTP redirection with the necessary variables from hotspot). I made a presentation years ago - there are only slides (ask MikroTi...
by dasiu
Sat Jul 21, 2018 12:08 pm
Forum: Scripting
Topic: Problem with route remove
Replies: 2
Views: 125

Re: Problem with route remove

I have this route: /ip route add dst-address=4.4.4.4 gateway=177.89.160.1 comment=FailOver And i trying this and don't work. /ip route remove [find dst-address=4.2.2.2] You know, that 4.4.4.4 is not the same as 4.2.2.2 - so there is no surprise :). Still - use quotation marks, /ip route remove [fin...
by dasiu
Thu Jul 19, 2018 12:41 pm
Forum: The Dude
Topic: Add images to device Dude 6.40.8
Replies: 3
Views: 257

Re: Add images to device Dude 6.40.8

Upload the file with Winbox/FTP/SCP/anything... to the RouterOS filesystem (to the dude directory - I prefer to create a new subdirectory, as the default images are in the "static" directory you can't change).
by dasiu
Wed Jul 18, 2018 6:26 pm
Forum: Scripting
Topic: No good connection alert
Replies: 1
Views: 103

Re: No good connection alert

Hi, 1. Netwatch - no, it's too basic 2. Script scheduled to run every minute (or so) would do. The script would run ping to the other side with interval set to 150 ms and with specified count (like 10 or 100 pings) - if the latency is higher, the pings will drop - and then based on the drop number (...
by dasiu
Wed Jul 18, 2018 6:21 pm
Forum: RouterBOARD hardware
Topic: Guidance to choose mikrotik device
Replies: 4
Views: 275

Re: Guidance to choose mikrotik device

The minimum would be really any MikroTik device - for such basic functionalities. That would be hEX lite for 40 USD:
https://mikrotik.com/product/RB750r2
To be sure you can do plenty more - you can go with hEX (60 USD and much more power):
https://mikrotik.com/product/RB750Gr3
by dasiu
Tue Jul 17, 2018 7:38 pm
Forum: Scripting
Topic: DNSdynamic script for RouterOS v6
Replies: 3
Views: 207

Re: DNSdynamic script for RouterOS v6

OMG, MSandoval! I didn't notice, that he included his real login information in the script! Thanks for pointing it out loud, so all of us now can notice it! :)
by dasiu
Tue Jul 17, 2018 1:29 pm
Forum: Scripting
Topic: Sending output of script commands to syslog
Replies: 6
Views: 279

Re: Sending output of script commands to syslog

You see the lines split, as the result of "print as-value" shows all entries in one string, and MikroTik splits the logged strings to 256-byte elements (256 bytes is the max length of what it can log). To send separate log for each line, try: :foreach logline in=[/ip firewall nat find dynamic=yes] d...
by dasiu
Fri Jul 13, 2018 3:47 pm
Forum: Scripting
Topic: check ip enabled or not [SOLVED]
Replies: 2
Views: 153

Re: check ip enabled or not [SOLVED]

Hi, I'd like to check if an ip address is enable or disable through script. How can I achieve this? example - :if (ip address get [find address="x.x.x.x/x"] disabled = yes) do={ ... - :if (ip address get [find address="x.x.x.x/x"] enabled = yes) do={ ... Thanks. Almost great, just work on the brack...
by dasiu
Fri Jul 13, 2018 3:35 pm
Forum: The Dude
Topic: [BUG] Images and icons disapearing
Replies: 18
Views: 868

Re: [BUG] Images and icons disapearing

Guys, I think I solved it in the past: Make sure the user you use for Dude access has FTP rights (the group the user belongs to)! You don't need the FTP protocol to be enabled (in IP services), but still seems like this policy is needed for the user to read the files from MikroTik filesystem - so yo...
by dasiu
Fri Jul 13, 2018 11:30 am
Forum: Scripting
Topic: routeros 6.42.5 and 6.42.6 script /file not working
Replies: 2
Views: 305

Re: routeros 6.42.5 and 6.42.6 script /file not working

What is wrong here? After the fetch, but before reading the file, put a short delay, like 2 seconds: :delay 2s; Unfortunately, this is how it works - the file that has just been downloaded/created locally - is not visible immediately, though the fetch command already finished its job. This is Mikro...
by dasiu
Tue Jul 10, 2018 5:49 pm
Forum: RouterBOARD hardware
Topic: RB3011 Switching Performance with Hardware Offloading
Replies: 7
Views: 736

Re: RB3011 Switching Performance with Hardware Offloading

There is always a third option :). If you need 5 or less ports - just use ports from one group for the LAN. (WAN, if it's just routed, without bridged VLAN, can be in the different group then) If you need 9 or 10 ports - then, unfortunately, you need an extra switch to work with wire-speed without u...
by dasiu
Thu Jul 05, 2018 11:31 am
Forum: The Dude
Topic: Install DUDE on RB2011
Replies: 1
Views: 245

Re: Install DUDE on RB2011

Install it on other machine :). My way: 1. Buy a VPS somewhere (I use vultr.com - virtual machine for 5 USD per month) and install CHR with a P1 license. 2. Make all your routers establish SSTP tunnels to the CHR. 3. Run the Dude on the CHR. It can monitor the machines and also devices inside the ne...
by dasiu
Wed Jul 04, 2018 6:48 pm
Forum: Scripting
Topic: Globals are emply from script but have a values at CL
Replies: 3
Views: 145

Re: Globals are emply from script but have a values at CL

In the beginning of each script you need to define the variables (even the global ones) you are using. You just need to do: :global URL; - so it's not changing the value, the variable is all the time there, it just makes the global variable "visible" from the "scope" of the script. You need to do th...
by dasiu
Tue Jul 03, 2018 12:43 am
Forum: Scripting
Topic: Bug in LEN [SOLVED]
Replies: 2
Views: 225

Re: Bug in LEN [SOLVED]

Your report is incorrect - it's NOT a BUG :). It's good, normal behaviour. 1. :len - returns not a "file size", but a "size of the variable". 2. /file find... - returns an ARRAY of POINTERS to files that match the "find" criteria. In your case /file find name=""... returns one pointer - so the lengt...
by dasiu
Fri Jun 29, 2018 12:19 am
Forum: Scripting
Topic: PUSHOVER - ready MikroTik script to send messages
Replies: 0
Views: 171

PUSHOVER - ready MikroTik script to send messages

I've just written a script (function) to send the Pushover messages directly from MikroTik, not using e-mail but direct API (faster). Just run once on bootup to "install" the functions: :global urlEncode do={ :local output "" :local input [:toarray $1] :if ([:len $input] > 0) do={ :local input1 [:to...
by dasiu
Thu Jun 28, 2018 1:45 pm
Forum: Scripting
Topic: Replace characters in string (url encode)
Replies: 11
Views: 7081

Re: Replace characters in string (url encode)

Also - check this out, this is how we now use the functions :). (please, see the "sticky" Functions and function parameters thread in this forum section!) :global urlEncode do={ :local output "" :local input [:toarray $1] :if ([:len $input] > 0) do={ :local input1 [:tostr [:pick $input 0]] :for i fr...
by dasiu
Thu Jun 28, 2018 1:22 pm
Forum: Scripting
Topic: Replace characters in string (url encode)
Replies: 11
Views: 7081

Re: Replace characters in string (url encode)

Let me suggest to make it nicer :). Instead of: :if (\$char = \" \") do={ :set \$char \"%20\" } :if (\$char = \"-\") do={ :set \$char \"%2D\" } :if (\$char = \"(\") do={ :set \$char \"%28\" } :if (\$char = \")\") do={ :set \$char \"%29\" } :if (\$char = \":\") do={ :set \$char \"%3A\" } You can use:...
by dasiu
Tue Jun 26, 2018 1:32 pm
Forum: Scripting
Topic: Function 'import' don't work with variables
Replies: 3
Views: 191

Re: Function 'import' don't work with variables

And I think it's normal behaviour, not a bug :). Your $lib variable is not "string", but a pointer to a file (try :put $lib, instead of :put [/file get $lib name]) :). You can use it in /file menu, but not in /import. You can also do /file print, find the entry number you like, and then remove it wi...
by dasiu
Tue Jun 26, 2018 1:28 pm
Forum: Scripting
Topic: Function 'import' don't work with variables
Replies: 3
Views: 191

Re: Function 'import' don't work with variables

Maybe try...
foreach lib in=[/file find name~".lib.rsc"] do={ :local libname [/file get $lib name]; :put $libname; /import "$libname" }
by dasiu
Fri Jun 22, 2018 11:06 am
Forum: Scripting
Topic: RB upgrade script issues
Replies: 2
Views: 184

Re: RB upgrade script issues

I'd add some debugging info: /system scheduler add interval=1d name=upgrade on-event=rb_upgrade policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive start-date=jun/16/2018 start-time=05:00:00 add name=startup_upgrade on-event=rb_upgrade policy=ftp,reboot,read,write,policy,test,password,...
by dasiu
Thu Jun 21, 2018 6:22 pm
Forum: Scripting
Topic: Day of the Week for a variable [SOLVED]
Replies: 2
Views: 162

Re: Day of the Week for a variable [SOLVED]

1. Unfortunately, MikroTik doesn't "show" the day anywhere.
2. Other people may already think about it. For example here:
https://wiki.mikrotik.com/wiki/Script_t ... f_the_week
by dasiu
Wed Jun 20, 2018 5:39 pm
Forum: Scripting
Topic: Scripting - Asking user for input.
Replies: 7
Views: 1485

Re: Scripting - Asking user for input.

Or use:
:put [$read] - to run the script (as for user input) and immediately put it on the screen without "storing it" in a variable :).
by dasiu
Tue Jun 19, 2018 3:58 am
Forum: Virtualization
Topic: CHR P-Unlimited - amount of L2TP - PPTP - EOIP ?
Replies: 6
Views: 317

Re: CHR P-Unlimited - amount of L2TP - PPTP - EOIP ?

No limit from the license.
But does anybody no what is the "limit" of the CHR - in terms when does it "die"? How many PPP interfaces or IPsec peers (or SAs) can we "run" on CHR (and if it scales when adding CPUs?) :)
by dasiu
Mon Jun 18, 2018 3:27 pm
Forum: Scripting
Topic: How to push and run script to CAP from CAPSMAN
Replies: 1
Views: 187

Re: How to push and run script to CAP from CAPSMAN

Yes. 1. On all CAPs enable FTP to be available only from the IP of CAPsMAN. 2. On CAPsMAN prepare the file like script.rsc, which will have the command to be sent to CAPs, like "/user set admin password=qwerty12". 3. On CAPsMAN write the script to get all IPs of CAPs and for each IP to run /tool fet...
by dasiu
Mon Jun 18, 2018 3:22 pm
Forum: Scripting
Topic: Script does not work at startup from /system script
Replies: 2
Views: 179

Re: Script does not work at startup from /system script

It's expected. Try reading about the "scopes" in the scripting manual - there is identical example.
https://wiki.mikrotik.com/wiki/Manual:S ... ocal_scope
Note that even variable can be defined as global, it will be available only from its scope unless it is not already defined.
by dasiu
Mon Jun 18, 2018 3:18 pm
Forum: Scripting
Topic: changing variables for all users of same profile
Replies: 2
Views: 188

Re: changing variables for all users of same profile

Yes, you can :).

Example (the idea is always the same)
/ppp secret set [find profile=default-encryption] limit-bytes-in=XXX

or just:
/any command set [find fieldname=commonvalue] changedfield=newvalue
by dasiu
Thu Jun 14, 2018 6:02 pm
Forum: Scripting
Topic: How to stop script
Replies: 1
Views: 123

Re: How to stop script

:set counter 0
:do {:delay 1; :set $counter ($counter+1);} while=(([/system ntp client get last-update-before]=[]) and ($counter<60));
by dasiu
Wed Jun 13, 2018 7:14 pm
Forum: Scripting
Topic: Determining the speed of data transmission in the subnet by means of scripts or rules
Replies: 2
Views: 150

Re: Determining the speed of data transmission in the subnet by means of scripts or rules

You can't use torch with scripts (i.e. can't read the torch readings from a script). What you can do is to have a /queue simple - one entry for each IP from LAN. Then your script can just get the "rate" parameter for each queue entry and check upload or download (need some parsing to split up/down a...
by dasiu
Sat Jun 09, 2018 10:55 pm
Forum: Scripting
Topic: Auto Failover with DHCP Internet Ip
Replies: 1
Views: 148

Re: Auto Failover with DHCP Internet Ip

Yes, it is possible.
by dasiu
Sat Jun 09, 2018 1:20 am
Forum: Scripting
Topic: Variables in script calls. [SOLVED]
Replies: 5
Views: 230

Re: Variables in script calls. [SOLVED]

Nooo :). 1. Create this itaTime script with the definition I sent, the few line :global itaTime do={ ... } 2. Make a scheduler to run this script every startup 3. In your other script in the beginning include the line: :global itaTime 4. Inside the script just use the [$itaTime] "variable" (which is...
by dasiu
Fri Jun 08, 2018 2:22 pm
Forum: Scripting
Topic: Variables in script calls. [SOLVED]
Replies: 5
Views: 230

Re: Variables in script calls. [SOLVED]

Hi! 1. If the values are local, it's normal they won't work - as the script B has different "local" variables than the calling script. 2. With global values it should work. But make sure, that in the beginning of BOTH script B and calling script you declare :global xxx. And maybe use first :global x...
by dasiu
Fri Jun 08, 2018 10:30 am
Forum: Scripting
Topic: VPN connected script
Replies: 3
Views: 383

Re: VPN connected script

I am aware of that, but to do that I have to create multiple profiles for each user instead of assigning them to multiple users. If there are any flexible solution, let me know. You have 2 options: 1. Create 2 scripts (on-up and on-down) for each user separately 2. Read The ....... Manual :) on-up ...
by dasiu
Wed Jun 06, 2018 3:04 pm
Forum: Scripting
Topic: Time range test [SOLVED]
Replies: 2
Views: 163

Re: Time range test [SOLVED]

if (($timetest>00:00:00) and ($timetest<09:00:00)) do={...
by dasiu
Wed Jun 06, 2018 12:17 pm
Forum: Scripting
Topic: What is the working method to define and clear an array?
Replies: 3
Views: 241

Re: What is the working method to define and clear an array?

There is a bug, I already reported it. I believe it should work like you presented. Please, see this example script, it's even better :) :local xxx {"Key 0"="Value 0"} :put "Initial array:" :put $xxx :set ($xxx->"Key 1") "Value 1" :put "Array after using set:" :put $xxx :set $xxx ($xxx,{"Key 2"="Val...
by dasiu
Wed Jun 06, 2018 11:42 am
Forum: Beginner Basics
Topic: RouterOS Downgrade
Replies: 4
Views: 253

Re: RouterOS Downgrade

make sure also that 6.33.1 is supported for CCR1009-7G-1C. You can check it in System -> Resources and check for "Factory Software" You can not go lower than this version.
That's probably the issue. 6.33.1 is November 2015 - probably this model is too new to be supported by that software.
by dasiu
Tue Jun 05, 2018 11:08 pm
Forum: Scripting
Topic: Testing to see if script is runing
Replies: 3
Views: 180

Re: Testing to see if script is runing

Partially only. Use:
:execute "/system script run $SCRIPT";
The execute will be in background, parent script will run till the end independently, but still will be visible on scripts list as it is the parent.
by dasiu
Tue Jun 05, 2018 7:30 pm
Forum: Scripting
Topic: Script for multiple routers [SOLVED]
Replies: 1
Views: 183

Re: Script for multiple routers [SOLVED]

Allow FTP on the routers (only for specific IP, recommended - either locally or via a secure tunnel, not just "from the internet"). Then you can use: https://wiki.mikrotik.com/wiki/Manual:Configuration_Management#Automatic_Import Just upload the script commands using FTP as a file with extension .au...
by dasiu
Tue Jun 05, 2018 7:21 pm
Forum: Scripting
Topic: Help me with fetch
Replies: 2
Views: 179

Re: Help me with fetch

Have you tried: /tool fetch http-method=post http-data="payload={\"username\":\"someuser\"\n\"password\":\"somepass\"}" url="https://provider.ltd/path-to-script.php" ? Or maybe: /tool fetch http-method=post http-data="username=someuser&password=somepass" url="https://provider.ltd/path-to-script.php" ?
by dasiu
Tue Jun 05, 2018 7:07 pm
Forum: Scripting
Topic: Testing to see if script is runing
Replies: 3
Views: 180

Re: Testing to see if script is runing

Simplify it a bit - and it will work :)
:local SCRIPT "script1"
:local RUNNING [/system script job find script="$SCRIPT"]
:if ([:len $RUNNING] = 0) do={/system script run $SCRIPT}