$ w
01:00:47 up 1 day, 23:51, 9 users, load average: 0.00, 0.04, 0.07
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
kevmitch tty7 :0 Sun03 0.00s 8:36m 0.04s
/bin/bash /home/kevmitch/.xsession
kevmitch pts/1 :0 00:57 2.00s 0.22s 0.02s aterm
kevmitch pts/2 :0 00:55 5:01m 0.17s 0.17s bash
kevmitch pts/4 :0 13:27 3:07 0.77s 0.77s bash
kevmitch pts/5 :0 23:49 14:05m 3.51s 0.00s
/bin/sh /usr/local/bin/matlab -nosplash -
kevmitch pts/6 :0 18:48 6:12 0.26s 0.26s bash
kevmitch pts/7 :0 18:49 3:08 2.09s 0.00s
/bin/sh /usr/local/bin/matlab -nosplash -
kevmitch pts/8 :0 00:56 3:48m 0.19s 0.19s bash
kevmitch pts/9 :0.0 01:00 0.00s 0.19s 0.00s w
All the pts's are the xterminals I have open. The ones without ".0"
are aterm's started via key bindings in Openbox. The lone :0.0 is one
that I started by typing "aterm" on the command line of an already
open xterminal. Don't ask me why that makes a difference :)
Kevin
On Mon, Sep 8, 2008 at 12:46 AM, Bart Samwel <[EMAIL PROTECTED]> wrote:
> Hi Kevin,
>
> Kevin Mitchell wrote:
>>
>> Looks good, except that that doesn't stop after finding the first user
>> so that I get
>>
>> $ displaynum=0
>> $ user=`w -hs | awk '{ if ($3 == ":'$displaynum'" || $2 ==
>> ":'$displaynum'" ) print $1; }'`
>> $ echo $user
>> kevmitch kevmitch kevmitch kevmitch kevmitch kevmitch kevmitch
>>
>> The following seems to return a unique value however:
>>
>> $ user=`w -hs | awk '{ if ($3 == ":'$displaynum'" || $2 ==
>> ":'$displaynum'" ) {print $1;nextfile}; }'`
>> $ echo $user
>> kevmitch
>>
>> Not sure if that's necessarily the "correct" way to do it but it seems
>> to work in my case.
>
> Seems fine to me. Alternatively I could pipe it through head -n 1. But I'm
> actually interested why you have multiple lines that match ":0" in your "w
> -hs" output. What does w -hs show for you?
>
>> PS: When does displaynum appear in the tty column?
>
> It turns out that with xdm, the displaynum appears in the TTY column, while
> with gdm, it appears in the From column. Apparently xdm does the right
> thing, but gdm doesn't register its session in wtmp. Or at least, that was
> suggested by the reporters of the original bug which caused me to change
> this code...
>
> Cheers,
> Bart
>
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]