Bug#497999: acpi-support: but there are bigger problems ...
Hi Kevin, I've uploaded a fix for this final problem, using a fix similar to what you suggested but using exit instead of nextfile. The reason is that nextfile is gawk-only, while exit is supported by both gawk and mawk, and it does the same thing in this situation. Let's just hope that it works now! Cheers, Bart Bart Samwel wrote: Hi Kevin, Well, at least this *looks* a bit reassuring. And we always grabbed the first one in the past, so this will probably be fine in practice. Thanks for all of the extra info! Cheers, Bart Kevin Mitchell wrote: It looks like openbox (or whatever is logging the terminals) knows not to cause this sort of trouble. I added a sudo aterm shortcut and when I fire it up, I get USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT kevmitch tty7 :0 09:030.00s 13.38s 0.04s /bin/bash /home/kevmitch/.xsession kevmitch pts/1:0 09:035:55m 0.02s 0.02s mutt kevmitch pts/0:0 09:035:55m 0.13s 0.13s bash kevmitch pts/2:0 09:033:47m 0.41s 0.04s /usr/bin/aterm -geometry 106x32-640-412 - kevmitch pts/3:0 09:051:32m 0.22s 0.22s bash root pts/5:0.0 09:071:33m 0.20s 0.20s bash root pts/6:0.0 09:090.00s 0.18s 0.00s w So it appends the extra .0 when it might cause confusion. In any case, it might have been all right even if this wasn't the case, since the real login TTY seems to always be the first in the list. Thus, truncating to just the first result would have prevented any root :0 from spoiling the pudding. That probably wouldn't be very reassuring though, because who knows if that ordering is set in stone. Kevin On Mon, Sep 8, 2008 at 1:20 AM, Bart Samwel [EMAIL PROTECTED] wrote: Hi Kevin, Kevin Mitchell wrote: $ 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 Sun030.00s 8:36m 0.04s /bin/bash /home/kevmitch/.xsession kevmitch pts/1:0 00:572.00s 0.22s 0.02s aterm kevmitch pts/2:0 00:555:01m 0.17s 0.17s bash kevmitch pts/4:0 13:273: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:486:12 0.26s 0.26s bash kevmitch pts/7:0 18:493:08 2.09s 0.00s /bin/sh /usr/local/bin/matlab -nosplash - kevmitch pts/8:0 00:563:48m 0.19s 0.19s bash kevmitch pts/9:0.0 01:000.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 :) Thanks for the info. I hadn't seen this type before -- all cases I've seen up till now showed one entry for :0 and all terminal entries for :0.0. What I'm wondering is if you can get it to show a different user name while still showing :0, for instance rootpts/4:0 13:273:07 0.77s 0.77s bash if you edit the Openbox config and edit the hotkey to start something like sudo aterm command line or something similar. Because then I'm getting *really* unhappy about how this looks... Cheers, Bart -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Bug#497999: acpi-support: but there are bigger problems ...
Hi Kevin, Kevin Mitchell wrote: Looking a littler closer, there are more problems than just this typo. *) This loop is attempting to match $displaynum rather than :$displaynum *) Variables inside the | while read construct are only local to within the loop (probably because it's executed in some sort of subshell or something), so $user never actually gets set. I tried to export it, but that didn't work eiither. Instead, the patch attached (again to be applied to power-funcs file itself) reverts back to something closer to the old method, but using w instead of finger as this was noted to be more reliable. Thanks for the scrutiny -- apparently I failed to test this batch of changes, blindly trusting the fact that I copied most of it from laptop-mode-tools. Stupid me. Anyway, the reason to go to the read construct was also the fact that filtering for :0 would also match a significant percentage of all logged in times (the fourth column in the output of w, and also present in the finger output). And it also matches entries which contain :0.0, which are present for terminal emulators. We really need to check only the second and third columns for display numbers, and we need to do exact matches only. So I think I'll go for this awk-based solution: user=`w -hs | awk '{ if ($3 == :'$displaynum' || $2 == :'$displaynum' ) print $1; }'` Does that work for you? Cheers, Bart -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Bug#497999: acpi-support: but there are bigger problems ...
Package: acpi-support Followup-For: Bug #497999 Looking a littler closer, there are more problems than just this typo. *) This loop is attempting to match $displaynum rather than :$displaynum *) Variables inside the | while read construct are only local to within the loop (probably because it's executed in some sort of subshell or something), so $user never actually gets set. I tried to export it, but that didn't work eiither. Instead, the patch attached (again to be applied to power-funcs file itself) reverts back to something closer to the old method, but using w instead of finger as this was noted to be more reliable. Kevin -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (600, 'unstable'), (500, 'testing'), (400, 'stable'), (300, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 2.6.27-rc5-amd64.010 (SMP w/2 CPU cores) Locale: LANG=en_GB, LC_CTYPE=en_GB (charmap=ISO-8859-1) (ignored: LC_ALL set to en_GB) Shell: /bin/sh linked to /bin/dash Versions of packages acpi-support depends on: ii acpi-support-base 0.109-7scripts for handling base ACPI eve ii acpid 1.0.6-10 Utilities for using ACPI power man ii dmidecode 2.9-1 Dump Desktop Management Interface ii finger0.17-12user information lookup program ii hdparm8.9-2 tune hard disk parameters for high ii laptop-detect 0.13.7 attempt to detect a laptop ii libc6 2.7-13 GNU C Library: Shared libraries ii lsb-base 3.2-20 Linux Standard Base 3.2 init scrip ii powermgmt-base1.30+nmu1 Common utils and configs for power ii vbetool 1.0-3 run real-mode video BIOS code to a ii x11-xserver-utils 7.3+5 X server utilities Versions of packages acpi-support recommends: ii dbus 1.2.1-3simple interprocess messaging syst ii hal 0.5.11-3 Hardware Abstraction Layer pn nvclock none (no description available) ii pm-utils 1.1.2.4-1 utilities and scripts for power ma pn radeontoolnone (no description available) Versions of packages acpi-support suggests: ii laptop-mode-tools 1.45-1 Scripts to spin down hard drive an -- no debconf information 11,16c11 w -hs | while read -r THIS_USER THIS_TTY THIS_FROM DUMMY_REMAINDER; do if [ $THIS_TTY = $displaynum -o $THIS_FROM = $displaynum] ; then user=$THIS_USER break fi done --- user=`w -hs | grep -m1 :$displaynum | awk '{print $1}'`