function info = machine_info(opt)
% Returns information about the machine matlab is running on.
%
% info = machine_info(opt)
%
% opt: this is character array passed as an option in a call to uname as
%      below  (Note that uname itself is sometimes system dependent and
%      so some of these options may not apply: 
%      uname prints information that identifies the current system to
%      standard output.  The options cause selected information returned by
%      uname(2) to be printed:
%  
%      -a   Behave as though all of the options -mnrsv were specified.
%  
%      -m   Print the machine hardware name.  This is the type of CPU board that
%           the system is running on, e.g.  IP22.
%  
%      -n   Print the hostname or nodename.  The nodename is the name by which
%           the system is known to communications networks.
%  
%      -p   Print the (informal) name of the current system's instruction set
%           architecture.  See the SI_ARCHITECTURE section of sysinfo(2).
%  
%      -r   Print the operating system release.  This string has one of the
%           following forms:  m.n or m.n.a where m is the major release number,
%           n is the minor release number and a is the (optional) maintenance
%           level of the release; e.g.  3.2 or 3.2.1.
%  
%      -R   Print the extended release name, usually the name of a hardware
%           specific release.  Implies the -r option.  The string returned will
%           be empty (that is, the -r and -R options will produce the same
%           output) on the base OS release.  This option shows additional
%           information similar to that printed on the CD label for hardware
%           specific releases.
%  
%      -s   Print the (operating) system name (the default).
%  
%      -v   Print the operating system version.  This is the date and time that
%           the operating system was generated, and has the form: mmddhhmm.

% $Id: machine_info.m,v 1.2 1997/06/10 06:34:21 mansbrid Exp mansbrid $ 
% Copyright J. V. Mansbridge, CSIRO, Tue May 27 14:56:03 EST 1997

% Check

if nargin == 0
  opt = 's';
elseif nargin ~= 1
  help machine_info
end

% Strip the minus sign if there is one.

if strcmp(opt(1), '-')
  opt = opt(2:length(opt));
end
[s, info] = unix([ 'uname -' opt ]);
info = info(1:(length(info)-1));  % Strip off the linefeed

return

% The following code used to work but stopped.  After changing this I found
% that the problem was due to driftwood running out of processes so that
% eval(str) does not actually write to the file.  In general the code should
% work.

% str = ['!uname -' opt ' >! /tmp/uname_tmp.dat'];
% eval(str);
% fid = fopen('/tmp/uname_tmp.dat','r');
% f = fgetl(fid);
% % info = setstr(f);
% !rm /tmp/uname_tmp.dat
