On 6/6/05, Randall R Schulz
Markus,
On Monday 06 June 2005 07:04, Markus Natter wrote:
On 6/6/05, Randall R Schulz
wrote: ...
Put this in a file, make it executable and put the file in a directory in your PATH. Call it "di", perhaps?
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==- #!/bin/bash --norc
getent passwd uid "$@" |sed -e 's/:.*//' -==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
The down-side is that you get no output and no diagnostic for unknown ID. Fixing that can be an "exercise for the reader."
Andreas
Randall Schulz
thanks,
something like this should do it then, if the ID is unknown..
-- snip -- #!/bin/bash
res=$(getent passwd uid "$@" |sed -e 's/:.*//') if [ "$res" == "" ]; then echo "unknown user id" exit 2
fi -- snap --
Not really. There are two problems:
1) That will only give the diagnostic when none of the IDs passed are found by getent. 2) It produces only diagnostic output.
Try this:
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==- #!/bin/bash --norc
for id; do pwEnt="$(getent passwd uid "$id")"
if [ ! "$pwEnt" ]; then echo "di: User id $id unknown" >&2 else echo "$id: ${pwEnt%%:*}" fi done -==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
markus
Randall Schulz
-- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
Hi Randall, I've forgotten to put the else part in mail.. and to redirect the output to stderr.. It's not my day.. beeing able to give more than one ID at a time is much more than I thought of, but a million thanks, Markus