Linux, APC: How to show status of the APC UPS in Linux?

robert@localhost$ apcaccess status

Show only STATUS: online or battery.
robert@localhost$ apcaccess status | grep STATUS | awk ‚{print $3}’

Ok, write small script to check if UPS is online.
Create apc_status.sh file, put below code inside of the file, write the file, add execute permission to file (chmod +x apc_status.sh).

#!/bin/bash
$status=`apcaccess status | grep STATUS | awk ‚{print $3}’`

if [ $status == „ONLINE” ]; then
echo „ONLINE”
exit 0
else
echo „ON BATTERY” | mailx -s „APC Status” user@domain.com
fi

Information:
„command”, ‚command’ – command is a string and go to variable
`command` – command is executed and output go to variable

Source: http://www.apcupsd.org/manual/manual.html