from
Get Network Address
by Ben Langhals
Returns the physical (mac) and IP address of your machine.
|
| getaddress
|
function varargout = getaddress
% GETADDRESS get address of machine
% mac = getaddress returns the physical (mac) adddress of the machine.
% [mac, ip] = getaddress returns the physical address of the machine and
% the IP address of the machine
% Author: Ben Langhals
if ~ispc
error('GETADDRESS is only supported on windows');
end
error(nargchk(0,0,nargin));
error(nargoutchk(1,2, nargout));
[status, result] = dos('ipconfig /all');
[start, finish] = regexp(result, '\w*-\w*-\w*-\w*-\w*-\w*');
macaddress = result(start(1):finish(1));
[start, finish] = regexp(result, '\d*\.\d*\.\d*\.\d*');
ipaddress = result(start(1):finish(1));
varargout{1} = macaddress;
if nargout == 2
varargout{2} = ipaddress;
end
|
|
Contact us at files@mathworks.com