Page 1 of 1

Getting MAC-address or alike in JS

Posted: 03 Oct 2016 17:28
by injecteer
How to get the MAC-address of Raspi in Javascript?
Another device-related unique identifier would also do...

Re: Getting MAC-address or alike in JS

Posted: 03 Oct 2016 17:57
by pz1

Code: Select all

host = system("hostname -I");
This seems to work without the need to register this command in /opt/z-way-server/automation/.syscommands

see hostname --help for other options

Re: Getting MAC-address or alike in JS

Posted: 04 Oct 2016 01:48
by injecteer
Thanks, you pointed me to the right direction!
I ended up using this:

Code: Select all

var mac = system( 'cat /sys/class/net/eth0/address' )[ 1 ].trim();
As soon as `cat` was not registered in `.syscommands`, I put it in and it worked like charm