diff options
| author | Andrew Tridgell <tridge@samba.org> | 2008-07-29 15:36:35 +1000 |
|---|---|---|
| committer | Andrew Tridgell <tridge@samba.org> | 2008-07-29 15:36:35 +1000 |
| commit | 346fd77a2acb9cb91540215e2137605cf084e2d2 (patch) | |
| tree | 83cde8a055afdbc7f33894d06b699ee7970427b4 /base | |
| parent | 1c3d1ba3ae793cc328bd1885ec96ea5a3d18d123 (diff) | |
split out waitfor
Diffstat (limited to 'base')
| -rwxr-xr-x | base/usr/bin/waitfor | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/base/usr/bin/waitfor b/base/usr/bin/waitfor new file mode 100755 index 0000000..cb296d3 --- /dev/null +++ b/base/usr/bin/waitfor @@ -0,0 +1,30 @@ +#!/bin/bash +# wait for a string to appear at the end of file +# tridge@samba.org July 2008 + +[ $# -lt 3 ] && { + cat <<EOF +Usage: waitfor FILE MESSAGE TIMEOUT +EOF +exit 1 +} + +file="$1" +msg="$2" +timeout="$3" + +tmpfile=`mktemp` + +cat <<EOF > $tmpfile +spawn tail -n 10000 -f $file +expect -timeout $timeout "$msg" +EOF + +expect $tmpfile +rm -f $tmpfile + +if ! grep "$msg" $file > /dev/null; then + echo "Failed to find \"$msg\" in $file" + exit 1 +fi +exit 0 |
