git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@477 
91ce42f0-d328-0410-95d8-
f526ca767f89
 
--- /dev/null
+#!/bin/sh
+#
+# Test if Bacula Client is alive
+#   exit 0 if specified client (arg1) is alive
+#   exit 1 if specified client (arg1) is NOT alive
+#   exit 2 if console could NOT connect with Director
+#
+OUTF=/tmp/client-${1}-alive
+rm -f ${OUTF}
+./console >/dev/null <<__EOD
+@output /dev/null
+messages
+@output ${OUTF}
+status client=${1}
+messages
+quit
+__EOD
+grep -s "Daemon started" ${OUTF} 2>&1 >/dev/null
+rtn=$?
+rm -f ${OUTF}
+exit ${rtn}
 
    }
    already_here = TRUE;
    free_pool_memory(args);
-   exit(0);
+   if (sig != 0) {
+      exit(1);
+   }
+   return;
 }
 
 #ifdef HAVE_READLINE