Click here for the code.

getmac is a tool on the PPT server that returns the MAC address of each phone associated with a given extension along with some additional information. It’s useful when an end user is able to provide an extension but not a MAC address for whatever reason. In most circumstances getmac will return a single result, however, in PPT folders where phones are moved between extensions frequently, multiple results will be returned. getmac parses the current working directory and will return an ls warning if used elsewhere.

An example use case would be trying to find the MAC address for the phone associated with extension 104 within /home/1900027:

getmac 104

This will return the following results:

-rwxrwxrwx 1 1900027 1900027 1611 Apr 19 2013 0004f2476c65.cfg
-rwxrwxrwx 1 1900027 1900027 1672 Feb 9 15:48 0004f28099ab.cfg
-rwxrwxrwx 1 1900027 1900027 1655 Jul 22 2015 0004f28c07e4.cfg

In this case we see three MAC addresses that have been associated with extension 104. The MAC address 0004f28099ab was edited most recently thus we can safely deduce that it is the MAC for the phone presently associated with the extension.

Again in most cases getmac will return a single result, thus eliminating the need to compare timestamps. The decision was made not to only have it return the most recent MAC address as returning all of them could prove useful in some circumstances.