[alt.sources] Grab effective user ID and group ID - Sys V

tneff@bfmny0.UUCP (Tom Neff) (08/15/89)

I love expr(1), don't you?  The possibilities are endless.  I needed to
grab my user and group name and I thought of this way of doing it using
the System V id(1) command.  It's faster than the sed(1) hack people
normally use.  You could run it on non-Sys V systems if you compile the
"uid.c" program that comes with, for instance, "deliver."  Of course if
you're bothering to do that you could just write two little one-shot C
programs, but that's not The Spirit now is it?

--- scratch & sniff here --- scratch & sniff here --- scratch & sniff here ---
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	myuid
#	mygid
# This archive created: Mon Aug 14 16:15:48 1989
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'myuid'
then
	echo shar: "will not over-write existing file 'myuid'"
else
sed 's/^X//' << \SHAR_EOF > 'myuid'
X:
X# myuid - display my effective user ID (System V)
Xexpr "`/usr/bin/id`" : '[^(]*(\([^)]*\))'
SHAR_EOF
chmod +x 'myuid'
fi
if test -f 'mygid'
then
	echo shar: "will not over-write existing file 'mygid'"
else
sed 's/^X//' << \SHAR_EOF > 'mygid'
X:
X# mygid - display my effective group ID (System V)
Xexpr "`/usr/bin/id`" : '[^(]*([^(]*(\([^)]*\))'
SHAR_EOF
chmod +x 'mygid'
fi
exit 0
#	End of shell archive

-- 
"We walked on the moon --	((	Tom Neff
	you be polite"		 )) 	tneff@bfmny0.UU.NET