1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#!/bin/sh
if test $# -eq 0 ; then
cat <<EOF
Usage:
$0 [ --timeout <seconds> ] <match>
Wait for pluto's non-debug logs to contain <match>
EOF
exit 1
fi
timeout=30
while test $# -gt 0 ; do
case $1 in
--timeout )
timeout="$2"
shift
shift
;;
* )
regex="$1"
shift
;;
esac
done
count=0
while count=$((count + 1)) && test ${count} -le ${timeout} ; do
input=$(grep -v -e '|' /tmp/pluto.log)
if output=$(echo "${input}" | grep "${regex}"); then
echo "${output}"
exit 0
fi
sleep 1
done
echo timeout waiting ${timeout} seconds for "${regex}" 1>&2
echo "${input}" | tail -100 | sed -e 's/^/output: /'
exit 1
|