apcupsd modification for X alerts

Need help with C, C++, perl, python, etc?

apcupsd modification for X alerts

Postby utrrrongeeb » 2006-09-21 10:05

I'm using apcupsd to monitor the UPS. At the moment, the control script calls wall whenever the power goes out, so everyone with a tty gets a message. However, everyone on X doesn't. I wrote a bash script that is launched on login to X, and it monitors a file. When the file is changed, it calls zenity with the contents of the file. The problem I'm having is that I'm having trouble both updating the file and calling wall from the control script.

The controller script, /etc/apcupsd/apccontrol, is somewhat like this:
Code: Select all
#defines a variable containing the name of the program to pipe the info to.
WALL=wall
#... various conditional code
#example notification line:
echo "The power's out. Save your work." | ${WALL}


What I want is the output to be written to /var/log/xwall, and also running wall, giving it the data in the same file.

When I change it to
WALL="tee /var/log/xwall | wall"

It doesn't work. It works with just wall, or with just tee, but not both.

Any responses are appreciated!
utrrrongeeb formerly lecaro
Art #429775 on 'Etch' 4.0r0
User avatar
utrrrongeeb
 
Posts: 255
Joined: 2006-05-14 09:48
Location: Eastern Canada

Postby greenhat » 2006-09-21 18:13

Is there any reason you couldn't simply use two lines in your script..
Code: Select all
echo "The power's out. Save your work." | wall
echo "The power's out. Save your work." | tee /var/log/xwall

greenhat
 
Posts: 170
Joined: 2006-06-03 17:32

Postby utrrrongeeb » 2006-09-22 10:04

The control script isn't my script; it is the script that came with the apcupsd package. (/etc/apcupsd/apccontrol)

However, that isn't so important now, as I finally got it to work.
/etc/apcupsd/apccontrol has WALL=tee /var/log/xwall . Each user's wm is configured to launch /usr/bin/xwall.sh on login, and I added an init script that launches /usr/bin/xwallmoni.sh.

xwall.sh checks the log file every second, and if the size has changed, it calls zenity with the contents of the file (and releases a cacophony of beeping).

xwallmoni.sh checks the log file every quarter second, and if the size has changed, it calls wall with the contents of the file.

Now that the UPS is working, I'll try to tackle the USB drives, the mouse, the sound system, including MIDI, and the Dell printers.

I can post my scripts if anyone wants to see them.
utrrrongeeb formerly lecaro
Art #429775 on 'Etch' 4.0r0
User avatar
utrrrongeeb
 
Posts: 255
Joined: 2006-05-14 09:48
Location: Eastern Canada


Return to Programming

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable