Aktualisiertes Skript. Problem ist nun: es wird nicht das richtige in die Datei OUTPUT_FILE2 geschrieben. es wird immer das print ausgeführt: print "$timestamp : Nicht alle Systeme verfügbar" >> $OUTPUT_FILE2. Auch wenn errors=0 ist.
Skript:
timestamp=$(date '+%Y%m%d-%H:%M:%S')
touch return$timestamp.log
ERROR_FILE="return$timestamp.log"
errors=$(grep "nicht verfügbar" return.log | wc -l)
errors2=`grep "nicht" return.log >/dev/null`
echo $errors2
echo $errors
if [ "$errors" = 0 ]; then
print "$timestamp : Alle Systeme verfügbar" >> $OUTPUT_FILE2
elif [ "$errors" > 0 ]; then
print "$errors2" >> $ERROR_FILE
print "$timestamp : Nicht alle Systeme verfügbar" >> $OUTPUT_FILE2
fi
Skript:
timestamp=$(date '+%Y%m%d-%H:%M:%S')
touch return$timestamp.log
ERROR_FILE="return$timestamp.log"
errors=$(grep "nicht verfügbar" return.log | wc -l)
errors2=`grep "nicht" return.log >/dev/null`
echo $errors2
echo $errors
if [ "$errors" = 0 ]; then
print "$timestamp : Alle Systeme verfügbar" >> $OUTPUT_FILE2
elif [ "$errors" > 0 ]; then
print "$errors2" >> $ERROR_FILE
print "$timestamp : Nicht alle Systeme verfügbar" >> $OUTPUT_FILE2
fi
Comment