I am trying to use a script to find the username and home directory of the user that is currently logged on to a Mac. This is what I have, and it works, but is there a better (i.e. simpler) way to do it?
user=`logname`
userHome="eval echo ~`echo $user`"
userHome=`$userHome`
The script will almost definitely not be run by the logged on user.
This is Mac OS X 10.6, joined to an Active Directory, and a network user is logged on. So the username does not appear in /etc/passwd
.