Fixing broken status loop
authorBrian Flowers <git-admn@bsflowers.net>
Mon, 19 Sep 2016 17:13:36 +0000 (13:13 -0400)
committerBrian Flowers <git-admn@bsflowers.net>
Mon, 19 Sep 2016 17:13:36 +0000 (13:13 -0400)
bdsm.sh

diff --git a/bdsm.sh b/bdsm.sh
index 9ccaa6a..82d2f6f 100755 (executable)
--- a/bdsm.sh
+++ b/bdsm.sh
@@ -234,7 +234,7 @@ status()
     functions=`cat /home/bdsm/.bdsm.conf.tmp | grep "$type:$host" | sed 's/.*{\(.*\)}.*/\1/'`
         
     j=0
-    echo $functions | tr ';' '\n' | sed 's/[(),]/ /g' | while read line; do
+    while read -u10 line; do
       command=`echo $line | cut -d' ' -f1`
       prefix="$type:$host|$command|"
       if [ -f /home/bdsm/bdsm.d/$command.$type ]; then
@@ -244,9 +244,9 @@ status()
       else
         error "Could not find plugin for $command on $type:$host!"
       fi
-    done
+    done 10< <(echo $functions | tr ';' '\n' | sed 's/[(),]/ /g')
     
-    pid=`cat /home/bdsm/pids/$host.in`
+    pid=`cat /home/bdsm/pids/$host.in 2>/dev/null`
     if [ ! -f /home/bdsm/pids/$host.in ]; then
       echo "$type:$host:MONITOR|???"
     elif [ `ps -p $pid | wc -l` -ge 2 ]; then