Advertisement
teknoraver

ups test

May 30th, 2017
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.37 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # wait for power loss
  4. while sleep .5 ; do
  5.     apcaccess |grep -q '^STATUS.*ONLINE' || break
  6. done
  7.  
  8. # set current time to zero
  9. date=$(date +%s)
  10. while sleep .5 ; do
  11.     pct=$(apcaccess |awk -F' +|\\.' '/^BCHARGE/{print$3}')
  12.     # if capacity is changed print it
  13.     if [ "$pct" != "$last" ]; then
  14.         echo $(($(date +%s)-date))
  15.         echo "Batt: $pct %"
  16.         last=$pct
  17.     fi
  18. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement