Hi, I use this function (now modified with elif) for check if a pc is up:
check_pc() {
$PING $PC 1 2> /dev/null
if [ $? -eq 0 ]; then
check_dir #Other function
echo "Begin backup operation for $PC"
echo "$SMBTAR -s $PC -u $USER -p $PASS -x $SHARE$EXCL -t - | gzip -c > $PC.tar.gz"
echo "End backup operation for $PC"
echo ""
elif [ $? -eq 1 ]; then
echo "Unable to ping $PC"
echo ""
else
#Not in /etc/hosts
echo "Unable to find $PC"
echo ""
fi
} #end check_pc
But.. With
$PING $PC 1 2> /dev/null
output like no answer from pc3 don't finish in /dev/null ... If I try
$PING $PC 1 > /dev/null
don't finish in /dev/null /usr/sbin/ping: unknown host pc123. How redirect error and output in /dev/null?
And.. can I use ping error to write in a log file "Unable to find $PC".. now the last else don't work. I use /bin/sh ... Thanks, bye.