Changeset 20442 for issm/trunk-jpl/src/m/os/oshostname.m
- Timestamp:
- 04/06/16 19:41:55 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/os/oshostname.m
r18739 r20442 1 1 function hostname=oshostname() 2 %OSHOSTNAME figure outhostname, irrespective of os type2 %OSHOSTNAME - Determine hostname, irrespective of os type 3 3 % 4 % usage: hostname=oshostname(); 5 % 6 % 4 % Usage: 5 % hostname=oshostname(); 7 6 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 8 if ispc 9 hostname = getenv('COMPUTERNAME'); 13 10 else 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'); 21 12 end 22 13 23 %remove carriage return and blank spaces 24 hostname=hostname(1:end-1); 25 hostname=ddewhite(hostname); 14 % Take out minus signs 15 hostname = strrep(hostname,'-',''); 16 17 % Check that machine name is not empty 18 if isempty(hostname), 19 error('Cannot determine machine name'); 20 end
Note:
See TracChangeset
for help on using the changeset viewer.