Changeset 22056
- Timestamp:
- 09/06/17 15:12:58 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/os/oshostname.m
r22055 r22056 5 5 % hostname=oshostname(); 6 6 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 8 hostname = ''; 10 9 11 % If that command did not work, we have an alternative 12 if status~=0, 10 %First try using java (most stable way) 11 if usejava('jvm'), 12 hostname = char(getHostName(java.net.InetAddress.getLocalHost)); 13 end 14 15 %Method 2: use system command (MATLAB bug includes what's in the clipboard) 16 if 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'); 20 end 21 22 %Method 3, last chance 23 if isempty(hostname), 13 24 if ispc 14 25 hostname = getenv('COMPUTERNAME'); … … 16 27 hostname = getenv('HOSTNAME'); 17 28 end 18 end19 20 % one more try using java....21 if isempty(hostname) & usejava('jvm'),22 hostname = char(getHostName(java.net.InetAddress.getLocalHost));23 29 end 24 30
Note:
See TracChangeset
for help on using the changeset viewer.