Code covered by the BSD License  

Highlights from
Get computer name/hostname

Get computer name/hostname

by

 

19 Sep 2007 (Updated )

It provides the computer name where running. Useful for customizing scripts depending on the machine

getComputerName()
function name = getComputerName()
% GETCOMPUTERNAME returns the name of the computer (hostname)
% name = getComputerName()
%
% WARN: output string is converted to lower case
%
%
% See also SYSTEM, GETENV, ISPC, ISUNIX
%
% m j m a r i n j (AT) y a h o o (DOT) e s
% (c) MJMJ/2007
% MOD: MJMJ/2013

[ret, name] = system('hostname');   

if ret ~= 0,
   if ispc
      name = getenv('COMPUTERNAME');
   else      
      name = getenv('HOSTNAME');      
   end
end
name = strtrim(lower(name));

Contact us