script to poweroff when running on UPS

Hi all,

The place where i stay experiences lot of power cuts and my solaris box is almost always on.
It so happens that many times i will not be around to switch it off as soon as there is a power cut..(i also have UPS which provides alternative supply for 15min)
So i wanted to write a script that can actually sense a power cut ,or at least sense that the power is being supplied from UPS and then automatically switch off....

I would like to try and write a script myself ,but dont know where i should start looking for the changes in the parameters when there is a power cut?
So could you please let me know where i can get these informations from and how i can use it in a script to initiate a shutdown?
Just a brief overview is sufficient ,as i would like to try writing a script myself...
If i cannot i will revert back!!!!

Thanks

if the ups is not connected (other than the power cord) with a serial line or via usb to your computer to give you the information that power is down... i also don't know where to start.
if there is a serial line (or usb) to your computer, you have to know how to read the needed information.

Have a look here:
Network UPS Tools
http://tldp.org/HOWTO/UPS-HOWTO/index.html

That is correct!!
I have the UPS connected only through a power chord.
Then links provided seem to be interesting...
Will revert back with some hopefully good news!!!