Martin Kraus wrote:
Hello,
  is there a standard way in debian to determine on what VT and display is X
running? Say I have a script that does something and I need to return output
to the user, but the user can be in linux console or in X or X doesn't have to
be running etc. So I need to determine if/where I should popup a window or
if I just need to send text to the console.

Thinking about it, is there any reliable way to find out how are different
users logged into the box? ssh,console,running X.

The 'who' command may be helpful. On my desktop system, logged in using 'kdm', running 'who -H' (-H prints headers), I get:

  NAME     LINE         TIME             COMMENT
  rmcgowan :0           2008-03-26 08:09

Note the LINE column reports ':0', which is the display in use.

On a Linux server, using 'ssh' to connect, the same command reports:

  NAME     LINE         TIME             COMMENT
  rmcgowan pts/0        2008-03-26 10:49 (ramjr.veritas.com)

Note two things here: the LINE value and the COMMENT. The COMMENT is the system from which I logged in.

And, with a console login, you get:

  rmcgowan tty1         2008-03-26 10:55

added to the two lines from the first example. Again, not the second (LINE) column.

In the case of pts/* and tty* values in the LINE column, you add '/dev/' as a prefix and you have the user's login device name, if needed.


thanks for help
mk



If you need to know about processes, check out 'ps' (obviously;-) and 'pstree'. If you need to know which connection the user has most recently used, use 'who -uH', which prints an IDLE column. In the case of X, it prints a '?', otherwise a dot if active, or the idle time, or 'old' if more than 24 hours (IIRC) old.

I hope this helps.

--
Bob McGowan
Symantec, Inc.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to