how to use M language get local Computer MAC Address
hi,ererybody!
help,
how to use M language get local Computer MAC Address?
I know get local ip use : w $ZU(67,15,$j),but i don't know this.
Comments
Look at https://irisdocs.intersystems.com/irislatest/csp/documatic/%25CSP.Documatic.cls for more info.
Thanks.But I have something wrong with my description,I want know how to use M get Computer physical address.
Really thank you,sir.Version 2010 don't have,version 2016 have this method.
Hi Vitaliy,
This is the same as 'write $SYSTEM.INetInfo.EthernetAddress(0)' in recent versions.
As said we prefer to not use $zu anymore, but since availability of the helper classes depend on what version is used, $zu might be the only possibility unless they upgrade.
Thank you Vitaliy,but just as Danny say,it is the same as 'write $SYSTEM.INetInfo.EthernetAddress(0)',and in cache 2010 I can not use '
w $$$DEFETHADDR'
What version are you using and on what platform (Caché/Ensemble/Iris) ?
I use cache 2010.
I know. After all the author requested the solution on pure M and not COS.
I checked for versions 2009.1/2010.1: unfortunately, the <FONT COLOR="#0000ff">$zu</FONT><FONT COLOR="#000000">(114,0)</FONT> returns nothing, therefore, remains variant with the command line.
Example for Windows, provided that the system has a single network card:
<FONT COLOR="#0000ff">#include </FONT><FONT COLOR="#000000">%syConfig </FONT><FONT COLOR="#0000ff">n </FONT><FONT COLOR="#800000">result </FONT><FONT COLOR="#0000ff">w $zu</FONT><FONT COLOR="#000000">(144,1,</FONT><FONT COLOR="#0000ff">$$$DEFETHADDR</FONT><FONT COLOR="#000000">),!,</FONT><FONT COLOR="#008000">"------"</FONT><FONT COLOR="#000000">,! </FONT><FONT COLOR="#0000ff">d $system</FONT><FONT COLOR="#008080">.OBJ</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">DisplayError</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Net.Remote.Utility</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">RunCommandViaCPIPE</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"getmac /NH /fo table"</FONT><FONT COLOR="#000000">,,.</FONT><FONT COLOR="#800000">result</FONT><FONT COLOR="#000000">)) </FONT><FONT COLOR="#0000ff">w $p</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">result</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">" "</FONT><FONT COLOR="#000000">,1)</FONT>PS: for other OS command line may be different.
Thank you again ,Vitaliy .
d $system.OBJ.DisplayError(##class(%Net.Remote.Utility).RunCommandViaCPIPE("getmac /NH /fo table",,.result))
w $p(result," ",1)this method might be return the server physical address.If I use this method on my pc (PC as server),it return ture physical address.
By default, the mac address of the computer on which the DBMS instance is running is returned. But you can get the mac address of any other computer, see getmac /?.

Hello,
This isn't the question you asked, but since you mentioned $ZU functions, please bear in mind that:
- $ZU functions are deprecated
- $ZU functions are no longer documented
- Users are encouraged to replace $ZU functions with methods and properties in InterSystems class libraries that perform the equivalent actions
Your specific example, $ZU(67,15,$j), is replaced by ##class(%SYSTEM.Process).ClientIPAddress($j).
Best,
Aaron
Try this:
<FONT COLOR="#0000ff">w $zu</FONT><FONT COLOR="#000000">(114,0)</FONT>or
<FONT COLOR="#0000ff">w $$$DEFETHADDR </FONT><FONT COLOR="#008000">; from %syConfig.inc</FONT>