Ignore:
Timestamp:
04/06/16 19:41:55 (9 years ago)
Author:
Mathieu Morlighem
Message:

CHG: simplified oshostname

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/os/oshostname.m

    r18739 r20442  
    11function hostname=oshostname()
    2 %OSHOSTNAME figure out hostname, irrespective of os type
     2%OSHOSTNAME - Determine hostname, irrespective of os type
    33%
    4 %   usage: hostname=oshostname();
    5 %
    6 %
     4%   Usage:
     5%      hostname=oshostname();
    76
    8 if ispc(),
    9         [status,hostname]=system('hostname');
    10         if status,
    11                 error('oshostname error message: could not run hostname command on windows os');
    12         end
     7% Find computer name from environment
     8if ispc
     9        hostname = getenv('COMPUTERNAME');
    1310else
    14         %See http://www.mathworks.com/help/matlab/ref/system.html "tips" section
    15         %We need to add < /dev/null otherwise what is in the clipboard is added
    16         [status,hostname]=system('hostname < /dev/null');
    17         hostname = strrep(hostname,'-','');
    18         if status,
    19                 error('oshostname error message: could not run hostname command on *nix os');
    20         end
     11        hostname = getenv('HOSTNAME');
    2112end
    2213
    23 %remove carriage return and blank spaces
    24 hostname=hostname(1:end-1);
    25 hostname=ddewhite(hostname);
     14% Take out minus signs
     15hostname = strrep(hostname,'-','');
     16
     17% Check that machine name is not empty
     18if isempty(hostname),
     19        error('Cannot determine machine name');
     20end
Note: See TracChangeset for help on using the changeset viewer.