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: Snaro on Mar 10, '03 11:10:01AM
You could also use this way:
system attribute "USER"
There are other variables available with system attribute:
"HOME": posix path to users home directory
"SHELL": posix path to users shell
"USER": users short name
"LANG": user system language as two-letter code e.g. "en_US"
"PATH": content of the PATH variable
"__CF_USER_TEXT_ENCODING": Don't know the meaning of this


[ Reply to This | # ]
Return the short username in AppleScript
Authored by: rbest on Mar 10, '03 11:31:53AM

I like the idea of user the 'system attribute' but forgive my ignorance, how do I USE it? (an example would be great)
Thanks!



[ Reply to This | # ]
Return the short username in AppleScript
Authored by: Anonymous on Mar 10, '03 11:51:46AM

Another option that I use a lot:

set myname to do shell script ("whoami")

Now myname is your shortname.

For other information, like path, you can pull that from the environment, but for username it's probably simpler to just use whoami.

Joel



[ Reply to This | # ]
Return the short username in AppleScript
Authored by: Eravau on Mar 10, '03 12:49:51PM
How to use it:
   set short_name to system attribute "USER"
Now the variable short_name will contain your short user name.

[ Reply to This | # ]
The AppleScript way
Authored by: Rainy Day on Mar 30, '12 02:02:34PM
Or:

set userName to short user name of (system info)


[ Reply to This | # ]