1#!/bin/bash 2 3set -e 4 5STRINGS=$(mktemp) 6ERRORS=$(mktemp) 7 8trap "rm $STRINGS; rm $ERRORS;" EXIT 9 10FILE=$1 11shift 1 12 13while getopts "f:e:" opt; do 14 case $opt in 15 f) echo "$OPTARG" >> $STRINGS;; 16 e) echo "$OPTARG" >> $STRINGS ; echo "$OPTARG" >> $ERRORS;; 17 esac 18done 19shift $((OPTIND -1)) 20 21echo "Waiting for $FILE to say one of following strings" 22cat $STRINGS 23 24while ! egrep -wf $STRINGS $FILE; do 25 sleep 2 26done 27 28if egrep -wf $ERRORS $FILE; then 29 exit 1 30fi 31