-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bill Campbell wrote:
> On Sat, Jan 27, 2007, Matthew Seaman wrote:
>> Bill Campbell wrote:
> ...
>>> Probably the most portable way to do this would be to use awk.  A
>>> simple script, homedir, might look like this:
>>>
>>> #!/bin/sh
>>> # getting the backwhacks correct is sometimes ``interesting''
>>> homedir=`awk -F: "/^$1:/{print \\$6}" /etc/passwd`
>>>
>>> [ -z "$homedir" ] && {
>>>     echo 'empty home for ' $1 2>&1
>>>     exit 1
>>> }
>>> echo $homedir
>>> exit 0
>> That does assume that all the user information is stored within the
>> local /etc/passwd -- if you're using NIS or LDAP or anything
>> like that, then you need a method that calls getpwnam(3) for you. 
> 
> A one-liner that should take care of these is:
> 
> python -c "import os.path; print os.path.expanduser('~$username')"
> 
> (This doesn't work with python-1.5.1 on an ancient Linux system
> as os.path didn't appear until later).
> 
> 
> Bill

Not all systems contain python though (and many don't), so $HOME is
still a better bet.

Thanks though for the idea,
- -Garrett
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.1 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFu8SGEnKyINQw/HARAvGpAJ4hbwv6YiF0rootWd/QTlQ1ZvweWgCgqwZ9
JCm3yiKBP2cX9dXwvIiYOz4=
=Cpfv
-----END PGP SIGNATURE-----
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to