• 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: How to find current user?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to find current user?


  • Subject: Re: How to find current user?
  • From: Roger Howard <email@hidden>
  • Date: Thu, 28 Oct 2004 17:14:49 -0700


On Oct 28, 2004, at 12:00 PM, Bernardo Hoehl wrote:

Is this what you want?

set CurrentUser to do shell script "whoami"

set ThePath to "/Users/" & CurrentUser & "/Library/Preferences/"

I would caution against this approach, especially for a lab scenario, as not all $HOME directories are located there, especially if it's a remote home directory (but even certain local accounts - root's $HOME is elsewhere). It will work on a stock OSX, but it won't handle many other scenarios.

I'd use the built-in AppleScript methods or possibly use "do shell script" to interact with niutil, which should be pretty authoritative for this info.

-R
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How to find current user?
      • From: Harald E Brandt <email@hidden>
    • Re: How to find current user?
      • From: Kent Behrends <email@hidden>
References: 
 >How to find current user? (From: Carl Jabido <email@hidden>)
 >Re: How to find current user? (From: Bernardo Hoehl <email@hidden>)

  • Prev by Date: sending SMS from Address book?
  • Next by Date: Re: How to find current user?
  • Previous by thread: Re: How to find current user?
  • Next by thread: Re: How to find current user?
  • Index(es):
    • Date
    • Thread