busyboxセッションでbashスクリプトを書いています。
スクリプトは、デーモン化された形式で外部実行可能ファイルを順番に何度も開始してから、出力を監視する必要があります。
LINEを読んでいる間while read LINE; do
VARIABLEPARAMETER=`echo "$LINE" | sed -e 's/appropriateregex(s)//'`
externalprog --daemonize -acton $VARIABLEPARAMETER -o /tmp/outputfile.txt
until [ "TRIGGERED" = "1" ]; do
WATCHOUTPUT=`tail -n30 /tmp/outputfile.txt`
TRIGGERED=`echo "$WATCHOUTPUT" | grep "keyword(s)"`
if [ -z "$TRIGGERED" ]; then
PROGID=`pgrep externalprog`
kill -2 "$PROGID"
continue
fi
done
done < /tmp/sourcedata.txt
私の質問は、2つのループのどちらに対してcontinueコマンドが実行されるかということです。
読み取り中の最初の行、またはトリガーされるまでの後続の行?
この質問を説明するための例として、これをまとめた実際のコードに焦点を当てないでください。実際のコードははるかに詳細です。
承認された回答:
「ヘルプ続行」から:
continue: continue [n]
Resume for, while, or until loops.
Resumes the next iteration of the enclosing FOR, WHILE or UNTIL loop.
If N is specified, resumes the Nth enclosing loop.
Exit Status:
The exit status is 0 unless N is not greater than or equal to 1.
したがって、continue
が必要です またはcontinue 1
until
の次の反復に進みます 、またはcontinue 2
while
の次の反復に移動します 。