Community discussions

Search found 2409 matches

  • 1
  • 2
  • 3
  • 4
  • 5
  • 49
by boen_robot
Fri May 24, 2019 9:42 am
Forum: Scripting
Topic: how to api print range
Replies: 1
Views: 95

Re: how to api print range

If there's a way to do it with scripting, there's a way to do it in the API. That said, I don't think there's a way to do it from scripting... RouterOS does let you scroll items interactively, and there's "no-paging" argument to make it not do that, but run down the screen immediatly. In the API, th...
by boen_robot
Tue May 21, 2019 3:43 pm
Forum: Scripting
Topic: Time Format Api Call
Replies: 2
Views: 155

Re: Time Format Api Call

You can still safely write "999d01:00:10". Just notice the lack of a space there. This is because the timeout is written as the scripting type "time", which supports this. You'll still get "42w5d1h10s" when you read it, but in terms of writing, it's fine. If you'd like to also read the Router's valu...
by boen_robot
Sun Apr 21, 2019 5:48 pm
Forum: General
Topic: ROS WebUI behind Apache reverse proxy
Replies: 2
Views: 227

Re: ROS WebUI behind Apache reverse proxy

Have a look at Chrome's developer tools (F12), and more specifically the network tab. Compare what you see there with what you'll get if you open up the router directly. This will give you a hint as to what may be going on. I would guess that what's happening is that RouterOS is producting full link...
by boen_robot
Sat Apr 13, 2019 8:07 pm
Forum: Scripting
Topic: Character Set
Replies: 6
Views: 416

Re: Character Set

BTW, fun fact I learned just now first hand... MikroTik's mobile app supports and defaults to UTF-8, while allowing you to switch encodings. Assuming WebFig does also use UTF-8 (I haven't checked), this means Winbox and terminal are the only environments where UTF-8 is not supported. Terminal doesn'...
by boen_robot
Wed Apr 10, 2019 2:29 pm
Forum: Scripting
Topic: API call all in one
Replies: 1
Views: 143

Re: API call all in one

You could use client's sendAsync() instead of the util methods. After making all sendAsync() calls, make a sequence of completeRequest() calls for each request, e.g. $client->sendAsync(new RouterOS\Request('/ip/hotspot/ip-binding/print', null, 'bindings')); $client->sendAsync(new RouterOS\Request('/...
by boen_robot
Sun Apr 07, 2019 11:31 pm
Forum: Scripting
Topic: Character Set
Replies: 6
Views: 416

Re: Character Set

Oh. Well, if Winbox doesn't allow you to type in both, then PHP is also working as expected. You have two options: 1. Write everything in Spanish. PEAR2_Net_RouterOS already uses iconv which should ignore (and therefore drop) all characters that Winbox would not allow you to type in. 2. Don't use ch...
by boen_robot
Sun Apr 07, 2019 5:32 pm
Forum: Scripting
Topic: Character Set
Replies: 6
Views: 416

Re: Character Set

What is your locale for non-Unicode applications (such as Winbox)? You can check by going to "Control Panel" > "Region" > "Administrative", under the "Current language for non-Unicode programs". Also if you click the "Change system locale", do you have the "use UTF-8..." checkbox checked? Displaying...
by boen_robot
Sun Apr 07, 2019 1:03 am
Forum: Scripting
Topic: Character Set
Replies: 6
Views: 416

Re: Character Set

In addition to the Content-Type HTTP header and PEAR2_Net_RouterOS' charset settings, your actual PHP file (i.e. where the string is written) also needs to be UTF-8 encoded. To get a good handle on what the correct remote charset is, try to type something from Winbox that does contain the weird char...
by boen_robot
Tue Mar 26, 2019 3:21 pm
Forum: Scripting
Topic: PEAR2 RouterOS API new login method. [SOLVED]
Replies: 2
Views: 263

Re: PEAR2 RouterOS API new login method. [SOLVED]

Does PEAR2 RouterOS already support the new login method? If you install with composer and using "dev-develop" as the version, yes. There is no PHAR release that includes this support yet. I haven't had time to prepare one. Also when the old login method will be removed from RouterOS? From the API ...
by boen_robot
Mon Mar 25, 2019 12:18 am
Forum: Scripting
Topic: PHP Api add user and password to Hotspot
Replies: 9
Views: 3666

Re: PHP Api add user and password to Hotspot

Surround the add() with a try/catch, and in the catch, check if the error is the one you recognize and act accordingly. I.e. either remove and add the user (or you know, just set() them instead of remove(), then add()), or do what you do for all other errors (e.g. rethrow the exception). Or you coul...
by boen_robot
Mon Mar 25, 2019 12:12 am
Forum: Scripting
Topic: userman with PHP
Replies: 1
Views: 211

Re: userman with PHP

"create-and-activate-profile" is a command, not a menu IIRC. It's not a normal CRUD command, so you'll have to make a request to give to Client, instead of using Util. Also, numbers should really contain the username (or otherwise the ID returned by finding the customer/username combo). e.g. $client...
by boen_robot
Mon Mar 25, 2019 12:04 am
Forum: Scripting
Topic: Net_RouterOS interface monitor-traffic
Replies: 1
Views: 261

Re: Net_RouterOS interface monitor-traffic

sendSync() waits for the command to finish executing. However, "/interface/monitor-traffic" is a continuous command - it never finishes executing until you manually stop it. You either have to pass the "once" argument to get just one sample in the $return, or use sendAsync() and loop()/completeReque...
by boen_robot
Sun Mar 24, 2019 11:51 pm
Forum: Scripting
Topic: PEAR2 RouterOS - Up/Downgrade Mikrotik
Replies: 1
Views: 170

Re: PEAR2 RouterOS - Up/Downgrade Mikrotik

AFAIK, a downgrade implicitly causes a reboot... Which means the API connection is closed. However, there's no indication to the client that the connection is being closed, which is why any command you would do after that would error. This API client in particular also sends a "/quit" command on con...
by boen_robot
Tue Jan 22, 2019 8:20 pm
Forum: Scripting
Topic: php api script
Replies: 1
Views: 242

Re: php api script

Using the API client from my signature: <?php require_once 'PEAR2_Net_RouterOS-1.0.0b6.phar'; use PEAR2\Net\RouterOS; $util = new RouterOS\Util( $client = new RouterOS\Client('192.168.88.1', 'admin', 'password') ); $monitorTrafficResponses = $client->sendSync($util->setMenu('/interface') ->newReques...
by boen_robot
Thu Jan 10, 2019 3:28 pm
Forum: Scripting
Topic: Help on php api
Replies: 15
Views: 1782

Re: Help on php api

What about running the actual ping from the API? If the results are important for later in the script, you can pass the relevant parts of the result as parameters in Util::exec(), and act accordingly. You can run the actual ping with $pingResults = $client->sendSync( $util->setMenu('/tool')->newRequ...
by boen_robot
Thu Jan 10, 2019 12:03 pm
Forum: Scripting
Topic: API. Listening interfaces and bridges doesn't report deletions
Replies: 3
Views: 310

Re: API. Listening interfaces and bridges doesn't report deletions

Yeah, I've also noticed that "/listen" is effectively an alias for "/print" with "follow-only" argument.

The .dead replies not being consistent across menus is probably a RouterOS bug.
by boen_robot
Thu Jan 10, 2019 11:42 am
Forum: Scripting
Topic: Help on php api
Replies: 15
Views: 1782

Re: Help on php api

You run it from the router how? Util::exec() uses "/system script run". If you're using f.e. scheduler, or /import a file, that's different. Also, Util::exec() prepends the current menu, while Script::prepare() doesn't (since it has no notion of a menu). If your script says "ping" rather than "/ping...
by boen_robot
Mon Jan 07, 2019 4:17 pm
Forum: Scripting
Topic: API. Listening interfaces and bridges doesn't report deletions
Replies: 3
Views: 310

Re: API. Listening interfaces and bridges doesn't report deletions

Try to use
/interface/print
=follow=
?dynamic=true
?#|
instead.

Print with "follow" behaves pretty much the same as "listen", as "print" is supposedly the only command that can accept queries.
by boen_robot
Mon Dec 24, 2018 4:21 pm
Forum: Scripting
Topic: API login
Replies: 1
Views: 380

Re: API login

That's an odd timing to get that sort of an error... What API client are you using? What is the code that results in this error? Are you connecting directly to the router, or over a VPN or SSH tunnel? I can imagine several scenarios where this can happen, but none of them involve connecting directly...
by boen_robot
Mon Dec 24, 2018 4:03 pm
Forum: Scripting
Topic: PHP API =follow=1
Replies: 3
Views: 1390

Re: PHP API =follow=1

If you mean how do you make completeResponse() work... you just don't call loop().
by boen_robot
Tue Oct 09, 2018 9:40 am
Forum: General
Topic: Custom Hotspot Server - Cache Control and Expires Headers
Replies: 2
Views: 960

Re: Custom Hotspot Server - Cache Control and Expires Headers

Any external server would require internet access, and hotspot prevents internet access. IMO, it's not worth the effort to cache hotspot page content, because users are supposed to get out of it as soon as possible and rarely see it. If you insist on caching it though, an external server is the way ...
by boen_robot
Tue Oct 09, 2018 9:37 am
Forum: Scripting
Topic: Android Ajax get not working
Replies: 1
Views: 231

Re: Android Ajax get not working

Hard to tell... You should do some debugging. Both on success and on failure, dump the response (e.g. in an alert), see what it says, and continue investigating possible causes from there.
by boen_robot
Thu Oct 04, 2018 11:33 am
Forum: Scripting
Topic: C# API - disable serial port
Replies: 2
Views: 333

Re: C# API - disable serial port

mikrotik.Send("/port/remote-access/set"); mikrotik.Send("=numbers=serial0"); mikrotik.Send("=disabled=true" , true); In general: 1. Target items with "=numbers=". 2. Specify properties to be modified with "=", name of property, "=", value. 3. For Boolean values, use "true" and "false" instead of te...
by boen_robot
Tue Sep 18, 2018 4:58 pm
Forum: Scripting
Topic: port tracking in php PEAR2 Api
Replies: 2
Views: 290

Re: port tracking in php PEAR2 Api

… And to do it on the app side, you can use preg_match while iterating over all items. You may narrow them down with other allowed criteria if you want (e.g. search for only tcp connections that come from a known interface) to optimize the performance somewhat. e.g. (without such criteria) foreach (...
by boen_robot
Thu Sep 06, 2018 2:52 pm
Forum: Scripting
Topic: Mikrotik synthesizer/piano programs
Replies: 16
Views: 2079

Re: Mikrotik synthesizer/piano programs

Requires VC2017 runtime I'd guess.
by boen_robot
Sun Aug 26, 2018 12:40 pm
Forum: Scripting
Topic: Get traffic usage via PEAR2 API
Replies: 2
Views: 494

Re: Get traffic usage via PEAR2 API

Using a specialized tool that analyzes SNMP and/or Netflow to generate a graph would be most efficient for the router indeed. If you're OK with sacrificing some of that efficiency for the purposes of customizable implementation, the other way would be to detect a new PPPoE interface appearing (see y...
by boen_robot
Sat Aug 25, 2018 7:56 pm
Forum: Scripting
Topic: Retrieve list of PPP Active and compare with ppp secrets
Replies: 8
Views: 1235

Re: Retrieve list of PPP Active and compare with ppp secrets

If you have shell access to your web server, you can run a PHP from the command line. You can also add it as a startup script if you want it to also restart with a server restart. Or use cron if you want to run it at regular intervals rather than continuously. If you run it continuously, you can use...
by boen_robot
Mon Aug 13, 2018 9:08 pm
Forum: Scripting
Topic: Scripting and [] commands in PEAR2_Net_RouterOS [SOLVED]
Replies: 2
Views: 422

Re: Scripting and [] commands in PEAR2_Net_RouterOS [SOLVED]

Easiest would be: $util = new RouterOS\Util($client); $util->setMenu('/ip firewall address-list')->disable(RouterOS\Query::where('address', '10.2.2.2')); Although there is a bug with Util and queries with multiple matches that's already fixed in the upcoming version... Until that version is released...
by boen_robot
Fri Aug 10, 2018 11:31 pm
Forum: Scripting
Topic: Class 'Phar' not found in /home/sharedhost/mysite/PEAR2_Net_RouterOS-1.0.0b6.phar on line 18
Replies: 2
Views: 333

Re: Class 'Phar' not found in /home/sharedhost/mysite/PEAR2_Net_RouterOS-1.0.0b6.phar on line 18

For some reason your shared host doesn't have the Phar extension, which is required to open PHAR files. It may be using PHP 5.2 or earlier, where Phar was not enabled by default, or it may be disabled by the host for some reason. If the problem is 5.2, there's no workaround - find a different host w...
by boen_robot
Sat Aug 04, 2018 6:11 pm
Forum: Scripting
Topic: API /export problem
Replies: 16
Views: 5224

Re: API /export problem

Is there any progress with API and export? We have PHP side where we would like to send / export... and download via FTP afterwards, but very often we receive onyl file with interrupted lines. Or, Is there any process how to reach full export? Thank you You could use PHP to create a scheduler scrip...
by boen_robot
Sat Jul 14, 2018 6:04 pm
Forum: Scripting
Topic: New Mikrotik - Using API to log users instead of RADIUS server
Replies: 2
Views: 610

Re: New Mikrotik - Using API to log users instead of RADIUS server

I assume you mean hotspot users. Yes, it's possible, but how easy it is depends on your topology. On successful authentication with your database, you'll need to create a temporary hotspot user with the API using the "/ip hotspot user add" command, then call the "/ip hotspot active login" command to...
by boen_robot
Mon Jul 09, 2018 5:31 pm
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 4666

Re: Change of Password for hotspot users

With that setup, it should work, as long as
1) Both of the ethernet ports on the MikroTik are on the same bridge.
2) You have excluded your web server from hotspot via a "bypassed" IP binding that also sets it to a fixed IP.
by boen_robot
Fri Jul 06, 2018 10:29 pm
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 4666

Re: Change of Password for hotspot users

It's generally not a good idea to have a web server running over Wi-Fi, precisely because of issues like this. The AP probably has "client isolation" enabled, meaning that Wi-Fi clients can't access either other. This is good for security, but bad if your goal IS for all Wi-Fi clients to see a parti...
by boen_robot
Fri Jun 29, 2018 9:00 am
Forum: Scripting
Topic: Using set() with PEAR2
Replies: 1
Views: 284

Re: Using set() with PEAR2

If the menu accepts names, you can just use it right there in place of the number, e.g. $util->set( 'myquota', array( 'limit-uptime' => $_GET['quota'] ) ); will look for an item named "myquota". If the item name contains a comma or matches the name of a function in PHP (and you don't want to call th...
by boen_robot
Sat Jun 23, 2018 2:29 pm
Forum: Scripting
Topic: Mikrotik API delete hosts
Replies: 2
Views: 376

Re: Mikrotik API delete hosts

With the client from my signature:
$util = new RouterOS\Util($client = new RouterOS\Client('192.168.88.1', 'admin', 'password'));

$util->setMenu('/ip hotspot host')->remove(RouterOS\Query::where('mac-address', '12:34:56:78:90:12'));
by boen_robot
Fri Jun 22, 2018 5:37 pm
Forum: Scripting
Topic: php API connection problem?
Replies: 16
Views: 6500

Re: php API connection problem?

Try the answers in the StackOverflow exchange linked above.
by boen_robot
Fri Jun 22, 2018 5:34 pm
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 4666

Re: Change of Password for hotspot users

Maybe retry the whole installation from the beginning. Remove the whole vendor dir, as well as composer.json and composer.lock. Then run composer init enter whatever details you want, but make sure "minimum-stability" says "beta". When asked to define dependencies, search for "pear2/net_routeros", a...
by boen_robot
Thu Jun 21, 2018 7:05 pm
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 4666

Re: Change of Password for hotspot users

Strange... Did the two composer commands succeed with no errors?

Maybe try calling "composer update" to double check everything is installed, and regenerate the autoloader.
by boen_robot
Wed Jun 20, 2018 5:45 pm
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 4666

Re: Change of Password for hotspot users

Run
composer config minimum-stability beta
and run
composer require pear2/net_routeros:@beta
again afterwards.
by boen_robot
Tue Jun 19, 2018 8:32 pm
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 4666

Re: Change of Password for hotspot users

It will be quickest if you download the .phar file , and include it instead of trying to install PEAR or Pyrus. Or alternatively, install composer , call "composer require pear2/net_routeros:@beta", and include "vendor/autoload.php". The latest version of the API client is not available from PEAR an...
by boen_robot
Sun Jun 17, 2018 12:08 am
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 4666

Re: Change of Password for hotspot users

There are several possible reasons. To narrow it down, you'll need to see some error messages from PHP. Open up your php.ini, and find the lines "display_errors", "error_reporting", "error_log", and set them to display_errors = Off log_erros = On error_reporting = E_ALL | E_STRICT error_log = "php_e...
by boen_robot
Fri Jun 15, 2018 9:17 am
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 4666

Re: Change of Password for hotspot users

The hotspot user credentials remain hosted on the router. The only thing you need to give to the script are credentials for a RouterOS user. From then on, the idea is similar to logging in from a terminal, and doing the commands on the router... Except that you're letting PHP do them automatically w...
by boen_robot
Tue Jun 05, 2018 10:19 am
Forum: Scripting
Topic: Help with PHP API
Replies: 3
Views: 559

Re: Help with PHP API

key part from this error message is [_type:PEAR2\Net\RouterOS\Response:private] => !trap [attributes:protected] => Array ( [message] => input does not match any value of parent ) Apparently, you have no queue named "testparent", and thus the add() call in "/queue simple" fails. Add "testparent" firs...
by boen_robot
Sun Jun 03, 2018 2:04 pm
Forum: Scripting
Topic: Help with PHP API
Replies: 3
Views: 559

Re: Help with PHP API

Using my PHP client: <?php require_once 'PEAR2_Net_RouterOS-1.0.0b6.phar'; use PEAR2\Net\RouterOS; $util = new RouterOS\Util($client = new RouterOS\Client('192.168.88.1', 'admin', 'password')); $util->setMenu('/ppp secret'); $util->remove('testuser'); $util->add( array( 'name' => 'testuser', 'passwo...
by boen_robot
Wed May 30, 2018 9:14 am
Forum: Scripting
Topic: "User hotspot change password itself"Mikrotik PHP API
Replies: 1
Views: 524

Re: "User hotspot change password itself"Mikrotik PHP API

What do you mean "can't change password"? Before all that... Can you successfully open up the web page and see the correct username you're already logged in with? Does the form get submitted successfully, and yet setting the password fail?Are there any error messages at any point? What version of PH...
by boen_robot
Sat May 26, 2018 12:09 pm
Forum: Scripting
Topic: Print output for hotspot users
Replies: 3
Views: 695

Re: Print output for hotspot users

You can use "print as-value" to save the output into a variable, that you can then loop over, and output in whatever fashion you want.

f.e.
:local users [/ip hotspot user print as-value];
:foreach user in=users do={
    :put ($user->"username");
    :put ($user->"password");
    :put "";
};[code]
by boen_robot
Wed May 16, 2018 7:01 pm
Forum: Scripting
Topic: Multiple commands through API [SOLVED]
Replies: 2
Views: 638

Re: Multiple commands through API [SOLVED]

Surrounding multiple commands on the command line with "{" and "}" and/or separating them with ";" isn't really combining them into one. The router still treats them as independent commands... I mean, you can't really combine commands into one call even on CLI, and thus not on API. You could make on...
by boen_robot
Wed May 16, 2018 6:53 pm
Forum: Scripting
Topic: running api as multi taksin C#?
Replies: 1
Views: 355

Re: running api as multi taksin C#?

Search and read detailed tutorials on "threads". That's the thing you want - make each new connection its own thread. That will make your management device move back and forth between the different routers, which works out great, since you want it to manage a different router, while it waits for one...
by boen_robot
Fri May 11, 2018 8:25 pm
Forum: Scripting
Topic: Limit to API Call
Replies: 2
Views: 456

Re: Limit to API Call

It's possible that the API client you're using isn't handling the network buffers well, so by the time it's finished processing what it has, the incoming packets have timed out, and it's not retrying. Or another possibility is that you have so many users in your client device's memory, that it can't...
by boen_robot
Tue May 08, 2018 9:38 pm
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 4666

Re: Change of Password for hotspot users

The router model would've been sufficient (unless it was an x86 PC) :D

How much RAM you need depends on which OS you're going to install, and i don't know of a TILE compatible one you can use. In general, if you can spare at least 256MiB for the guest, that would most probably work.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 49