Changeset 22056


Ignore:
Timestamp:
09/06/17 15:12:58 (8 years ago)
Author:
Mathieu Morlighem
Message:

CHG: better operation ordering

File:
1 edited

Legend:

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

    r22055 r22056  
    55%      hostname=oshostname();
    66
    7 %See http://www.mathworks.com/help/matlab/ref/system.html "tips" section
    8 %We need to add < /dev/null otherwise what is in the clipboard is added
    9 [status,hostname]=system('hostname < /dev/null');
     7%Initialize output
     8hostname = '';
    109
    11 % If that command did not work, we have an alternative
    12 if status~=0,
     10%First try using java (most stable way)
     11if usejava('jvm'),
     12        hostname = char(getHostName(java.net.InetAddress.getLocalHost));
     13end
     14
     15%Method 2: use system command (MATLAB bug includes what's in the clipboard)
     16if isempty(hostname),
     17        %See http://www.mathworks.com/help/matlab/ref/system.html "tips" section
     18        %We need to add < /dev/null otherwise what is in the clipboard is added
     19        [status,hostname]=system('hostname < /dev/null');
     20end
     21
     22%Method 3, last chance
     23if isempty(hostname),
    1324        if ispc
    1425                hostname = getenv('COMPUTERNAME');
     
    1627                hostname = getenv('HOSTNAME');
    1728        end
    18 end
    19 
    20 % one more try using java....
    21 if isempty(hostname) & usejava('jvm'),
    22         hostname = char(getHostName(java.net.InetAddress.getLocalHost));
    2329end
    2430
Note: See TracChangeset for help on using the changeset viewer.