• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Obtaining Current User Name
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Obtaining Current User Name


  • Subject: Re: Obtaining Current User Name
  • From: Russell Ahrens <email@hidden>
  • Date: Fri, 8 Jun 2001 00:29:42 -0400

From the command line, there are two ways: "whoami" and checking the USER or LOGNAME environment variable.

Programmatically, you can execute the system command "whoami", plop the output into a string, and use that. As for the environment variable, there is a UNIX extern C variable "environ". Check the man page for the exact details, but it seems that you can search it for a string "USER=" (or "LOGNAME=") and keeping the text immediately following.

I hope that there's an easier way, through Cocoa, but I haven't found anything yet. I'll keep looking.

Russell Ahrens
Oink Industries

On Thursday, June 7, 2001, at 08:53 PM, Karl Goiser wrote:

Hello,

Could somebody please tell me how to obtain information about the currently logged in user?

(Sorry if this is a dumb question, but I really don't know where to look...)

Karl

-- ----
Klaatu barada nikto
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev


References: 
 >Obtaining Current User Name (From: Karl Goiser <email@hidden>)

  • Prev by Date: Re: "Tricks" of the "Trade"
  • Next by Date: Re: Obtaining Current User Name
  • Previous by thread: Re: Obtaining Current User Name
  • Next by thread: Re: Obtaining Current User Name
  • Index(es):
    • Date
    • Thread