From: MERC::"uunet!WKUVX1.BITNET!MacroMan" 7-JUL-1992 19:23:01.49 To: MACRO32@WKUVX1.BITNET CC: Subj: Re: Getting username -- help please >> This is a trivial question -- one I expect someone has the code around to >> handle without much effort. I need to be able to find the username >> associated with the current process, as well as the "real" name associated >> with that username. I know this exists in the SYSUAF file, but don't have >> a clue how to get it out to do this (I can't find a combination of DCL >> lexicals, which I my real preference). I am wanting to port this output >> into TPU and can use a variety of TPU's commands to get to there. >> >> Any assistance or light anyone can shed on this will be very appreciated as >> we don't have any MACRO32/BLISS people around here and its my guess that's >> the best way to get what I want. Certainly, any route is acceptable. > > > Getting the current username from DCL is indeed trivial. The lexical >function you want is F$GETJPI("","USERNAME"). This returns a 12 character >string so you may want to use the F$EDIT TRIM function on it. Getting the >"real" name is harder. For a language you could use the $GETUAI service. >From TPU you can use CALL_USER to envoke a function the uses $GETJPI to >determine the username and $GETUAI to get the owner's name. From DCL, >there is not a clean interface to the SYSUAF file. You could simply open >it and READ/KEY=username to get the record into a symbol, then use the >F$EXTRACT lexical to get the owner's name. The $UAFDEF module in LIB.MLB >will give you the length and offset of the field. Or you can write (or >pick up somewhere) a GETUAI program that extracts information from the >SYSUAF. I am sure they exist on the net somewhere. >------- >Bruce A. Hudson | HUDSON@AC.DAL.CA >UCIS, Facilities and Operations | HUDSON@DALAC (Bitnet) >Dalhousie University | HUDSON@DALCS (UUCP) >Halifax, Nova Scotia, Canada | This might help: write sys$output f$getjpi(f$getjpi("","MASTER_PID"),"USERNAME")' i use it in a 'whoami' symbol, a la an executable login.exe written in pascal: LIB$SET_SYMBOL('WHOAMI','write sys$output f$getjpi(f$getjpi("","MASTER_PID"),"US ERNAME")',GLOB); very useful, especially when sitting down at a random logged in terminal. -cgw- -- christopher williams cgw@unt.edu +1 817 565 4161 lead programmer/operator, university of north texas