On Sun, 2 Aug 2020, Todd Benivegna wrote:

How would you write the SHUTDOWNCMD line with multiple commands?  I’ve been looking at the manual and see that you have to escape the internal “ but am
still a little confused on how to do this exactly.

This assumes that you use the Bash shell in your default environment. It will need adaption if you use Dash.

In .bashrc define function getUPSstatus

 # Update variable UPSstatus and export to environment
 # Usage getUPSstatus <myups>
 function getUPSstatus {
   export UPSstatus="[$( upsc $1 ups.status 2>/dev/null )]:$( upsc $1 battery.charge 
2>/dev/null )"
 }

The SHUTDOWNCMD declaration now simplifies to

 SHUTDOWNCMD "getUPSstatus <myups> ; logger -t upsmon.conf \"UPS status is 
$UPSstatus\" ; /sbin/shutdown -h +0"

Roger
_______________________________________________
Nut-upsuser mailing list
[email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser

Reply via email to