-
Notifications
You must be signed in to change notification settings - Fork 3
/
tz_machineinfo.m
60 lines (57 loc) · 2.07 KB
/
tz_machineinfo.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
function machine = tz_machineinfo(varargin)
%TZ_MACHINEINFO Get information of the machine
% TZ_MACHINEINFO(INFO1,...,INFON) returns machine information, which is
% stored in a struecture.
%
% Options for information:
% 'name': machine name
% 'computer': computer type (for details, type 'help computer')
% Copyright (C) 2006 Murphy Lab
% Carnegie Mellon University
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published
% by the Free Software Foundation; either version 2 of the License,
% or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
% General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
% 02110-1301, USA.
%
% For additional information visit http://murphylab.web.cmu.edu or
% send email to murphy@cmu.edu
% 24-May-2005 Initial write TINGZ
% Copyright (c) Murphy Lab, Carnegie Mellon University
for i=1:length(varargin)
switch varargin{i}
case 'name'
if exist('machine.mat','file')
load machine.mat
else
[s,hostname]=unix('hostname');
if uint8(hostname(end))==10
hostname=hostname(1:end-1);
end
dotpos=find(hostname=='.');
if isempty(dotpos)
machine.name=hostname;
else
machine.name=hostname(1:dotpos-1);
end
end
case 'computer'
machine.computertype = computer;
case 'domain'
[s,name]=unix('dnsdomainname');
if uint8(name(end))==10
name = name(1:end-1);
end
machine.domainname = name;
end
end