SUMMARY: Seeing if root is on the console

From: Spalding, Steve <SSPALDIN_at_mem-ins.com>
Date: Wed, 22 Apr 1998 09:21:04 -0500

My original message is:

"Hi managers!

> I put a message up on the list a while back regarding seeing who is
> logged onto the console which is running Xwindows, and the answer was
> to
> use the who command. Well, I've got a twist on this one...we want
> certain things in root's .profile to be executed when root logs in on
> the console terminal (which still runs Xwindows) but not when we su to
> root. When we su to root, we still want .profile to run as there is
> still other stuff in that file that needs to be executed for root when
> it's logged in.
>
> When we log in as root on the console, we have at least two dtterm
> sessions come up, and unfortunately, the parent id on these processes
> isn't the same as the owner process id that shows up owning the
> console
> port (I find this using the who -u command). Also, there is a
> corresponding process which is running ksh for each of the dtterm
> processes and there is no correlation between those processes and any
> of
> the other root processes.
>
> I have tried working with the last command where I set up a set of
> lines
> in .profile to execute when root logs in. Those lines check the
> date/time stamp on the process that shows as logged in on the console
> against the process that is currently running root's .profile. This
> idea
> works, but it has holes in it. I'm wondering if there is an easier way
> of doing this than what I am attempting to do.
>
> Thanks!"
>
>
Thanks to Serge Munhoven who put me on the right track. There's an
environment variable that is set whenever you log in, and it's different
for each different terminal (pc in this case) that you log into. This
variable is DISPLAY, and when I am logged on my pc, the DISPLAY variable
is set to sspaldin:0. When anyone is logged on the console, the variable
is set to either :0 or :0.0. So, in root's .profile, to check and see if
the process that is logging in is on the console, I will check to see if
DISPLAY=:0 or :0.0 and check to see (using the who command) if root owns
the console.

Thanks to everyone else for his/her input.

Regards,

Stephen Spalding
Received on Wed Apr 22 1998 - 16:27:09 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:37 NZDT