in reply to How to get the logged in user id

You may need to resort to using `tty` and the output of `who`. This will (normally) show who logged into the tty, and won't be affected by su.

Replies are listed 'Best First'.
Re: Re: How to get the logged in user id
by Matts (Deacon) on May 29, 2002 at 15:01 UTC
    Actually this is what I resorted to doing. The code already had getlogin() in it, but it was still returning root. I have no idea why, so I just used `tty` and `who | grep '$tty' | cut -d" " -f1`. Seems to work like a charm. ++ for you ;-)