Home > atmlab > handy > whoami.m

whoami

PURPOSE ^

WHOAMI Returns user name

SYNOPSIS ^

function user = whoami

DESCRIPTION ^

 WHOAMI   Returns user name

 FORMAT   user = whoami
        
 OUT   user   String with user name.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

whoami.m

SOURCE CODE ^

0001 % WHOAMI   Returns user name
0002 %
0003 % FORMAT   user = whoami
0004 %
0005 % OUT   user   String with user name.
0006 
0007 % 2005-02-15   Created by Patrick Eriksson.
0008 
0009 
0010 function user = whoami
0011 
0012 
0013 [s,user] = system( 'whoami' );
0014 
0015 if s
0016   error( 'System call to establish user name failed.' );
0017 end
0018 
0019 
0020 %= Remove domain name that can be included on Windows machines
0021 %
0022 if ispc
0023   i = find( user == '\' )
0024   if ~isempty(i)
0025     user = user((i+1):end);
0026   end
0027 end
0028 
0029 
0030 %- Remove any newline character
0031 %
0032 if user(end) == sprintf('\n')
0033   user = user(1:end-1);
0034 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005