Question
Bond Xu · Jul 23, 2019

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.

1
1 520
Discussion (14)3
Log in or sign up to continue

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 $zu(114,0) returns nothing, therefore, remains variant with the command line.

Example for Windows, provided that the system has a single network card:

#include %syConfig
 result
 w $zu(144,1,$$$DEFETHADDR),!,"------",!
 
 d $system.OBJ.DisplayError(##class(%Net.Remote.Utility).RunCommandViaCPIPE("getmac /NH /fo table",,.result))
 w $p(result," ",1)

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:

w $zu(114,0)

or

w $$$DEFETHADDR ; from %syConfig.inc