Code covered by the BSD License  

Highlights from
whoami: a pedestrian user id retriever

4.0

4.0 | 4 ratings Rate this file 4 Downloads (last 30 days) File Size: 2.77 KB File ID: #20321
image thumbnail

whoami: a pedestrian user id retriever

by us

 

17 Jun 2008 (Updated 23 Jun 2008)

whoami displays a full user id and retrieves system properties

| Watch this File

File Information
Description

WHOAMI displays a long user id (LID) in the form
%time|username|domain|hostname|osarch|osname|osver|MLver
 
WHOAMI optionally returns various system properties including a short user id (SID), which only contains static information about the current system
programmers can easily create their own IDs or change the built-in formats, which may be a useful tag in source control

example of the short output (note: formatting will most likely be bad)

>> w=whoami;
>> w
        magic: 'WHOAMI'
    WHOAMIver: '18-Jun-2008 13:47:52'
        MLver: '7.6.0.324.R2008a'
      runtime: '18-Jun-2008 14:02:09'
          sid: '%us|USZ|ws-nos-36362|x86|Windows XP|7.6.0.324.R2008a'
          lid: [1x77 char]
         name: 'us'
       domain: 'USZ'
         host: 'ws-nos-36362'
           ip: 'xxx.yyy.141.135'
       osarch: 'x86'
       osname: 'Windows XP'
        osver: '5.1'

see

>> help whoami

for further explanations of the self-explanatory snippet

Acknowledgements
This submission has inspired the following:
getUserName
MATLAB release MATLAB 7 (R14)
Other requirements the java engine must be loaded; the code was tested on various wintel systems only but SHOULD run on other systems as well
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (9)
17 Jun 2008 D Slav

Really poor!! and requires "wintel systems". User can get all this info with two lines of code of some extension, and without requirements!

17 Jun 2008 Urs (us) Schwarz

dear D Slav
thank you for your catchy comments...
firstly, i did not say requires wintel systems, i simply said: tested on wintel systems - after all it's using java...

then, i'd be very interested to see those two lines you mention... very interested...

did you even look at/run the snippet...
us

18 Jun 2008 w s

Works like a charm! As we are USed to...

20 Jun 2008 Urs (us) Schwarz

an enhanced version was uploaded several days ago but, unfortunately, has not shown up yet... if you seriously consider using this snippet, please wait until this update is ready (there will be a screenshot)...
us

21 Jun 2008 John D'Errico

(Tested the original version.) Does not require a wintel system. I just tested it on my mac - runs fine.

26 Jan 2009 Kevin J. Delaney

Works great on my Windows system! Nicely done.

10 Dec 2009 Az Nephi

if (isunix)
    user = getenv('USER');
else
    user = getenv('username');
end

29 Dec 2009 us

az nephi,
quite correct...
but this is only a small part of WHOAMI's output/capabilities...
us

07 Oct 2010 Amit Batifkoff

It has handles leak.

Please login to add a comment or rating.
Updates
23 Jun 2008

added more information in the help section and the screen shot, which got lost the first time; version tag 18-Jun-2008 13:47:52

Tag Activity for this File
Tag Applied By Date/Time
development environment us 22 Oct 2008 10:06:21
user us 22 Oct 2008 10:06:21
login us 22 Oct 2008 10:06:21
computer us 22 Oct 2008 10:06:21
system us 22 Oct 2008 10:06:21
java us 22 Oct 2008 10:06:21

Contact us at files@mathworks.com