Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Return the short username in AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Return the short username in AppleScript
Authored by: gatorparrots on Mar 10, '03 04:56:24PM
That may not work for scripts using sudo (or sudo -s) or the 'with administrator privileges' syntax in AppleScript (the same problem goes for any of these possiblities: $USER, 'users' and 'logname' -- there are situations where these facilites will return 'root' in response. To get the currently logged-in GUI username, a more reliable method would be this: who | grep console | awk '{print $1}' To call it from an AppleScript: set theuser to (do shell script "who | grep console | awk '{print $1}'")

[ Reply to This | # ]