Comments (3)
Sure.
$macAddress = $util->setMenu('/interface')->get('ether1', 'mac-address');
Just replace "ether1" with the name of the interface you want to get the MAC address of.
from net_routeros.
thanks for reply,
But the situation I have now that I have Mikrotik router connected to my captive portal and I want to get router mac address and send it to server
I tried this code
$client =new RouterOS\Client('192.168.88.1', 'admin', 'password');
`$snmpRequest = new RouterOS\Request(':put [/interface ethernet get [/interface ethernet find default-name=ether1] mac-address ]');`
$snmpResponses = $client->sendSync($snmpRequest);
`$nasID = RouterOS\Script::escapeString($snmpResponses->getProperty('value'), true);`
but while testing the captive portal stuck at this link --> http://192.168.88.1
note that I changed the password to current password
from net_routeros.
You can't use nested commands in Request(). You must call each command individually. Also, "put" is kind of useless in the API, though it does work... It's just that it can only output a string that it was explicitly given. Also, why are you calling RouterOS\Script::escapeString() on the returned value?
What probably happened in your code is there was an error reply, but you took its "value" property anyway.
You can emulate more closely the nested command syntax with Util, but the point remains even there:
$util = new RouterOS\Util($client);
$util->setMenu('/interface ethernet');
$nasID = $util->get(
$util->find(RouterOS\Query::where('default-name', 'ether1')),
'mac-address'
);
The above would give you the mac-address into the variable $nasID via two API calls - one to get the internal ID of the interface with default name "ether1", and the second one to get its mac-address. And it would throw an exception if there's an error reply anywhere.
from net_routeros.
Related Issues (20)
- utils find implementation error HOT 4
- Error installing with composer HOT 3
- Error in Codeigniter HOT 7
- phar file for download? HOT 1
- 6.45.8 - authentication failure HOT 2
- Hi, i already updated script to login with version 6.43.
- Caracters <> doesnt show ? HOT 2
- Unable to connect to the router HOT 4
- Authentication problem from RouterOS 6.45.6 HOT 1
- Workflow question HOT 4
- $response->getType return "!re" - what's going on? HOT 2
- "LIKE" in query HOT 1
- Best practice to add a large list HOT 4
- exec() problem HOT 2
- Persistent connection HOT 3
- Call "all" option on Hotspot Server submenu to use in Users submenu HOT 3
- Why can't I enable, disable or remove Hotspot Users? HOT 2
- Unable to login ROS v6.47.10 (long-term)
- Random Mac Address HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from net_routeros.