ksh は値によって中断され続けます。

ksh は値によって中断され続けます。

KSHシェルで次のスクリプトを実行しています。 Javaプログラムを呼び出すためにループを6回実行し、例外が見つからない場合は= 0を返す必要があります。 6回の繰り返しで例外が見つかった場合は、3を返す必要があります。

integer max=7;i=1

while [[ $i -lt $max ]]
do
    Java call statement;
    error_cnt=`$processing_file | grep -i excption | wc -l `
    if (( $error_cnt == 0 ))
    then
        return_code=0;
        break
    else
       Continue with java call 
    fi 
    (( i = i + 1 ))
done

6回の繰り返しのすべてでまだ例外が見つかった場合は、3を返す必要があります。

ベストアンサー1

を定義することを忘れないでください。あるいは、ファイルを直接$processing_file使用することもできます。grep

その後、エラーがなければ中断したいときにエラーがある場合はループを中断します。はい間違い。その後、ループが中断または完了した後に実際に戻りたいと思います$return_code

integer max=7;i=1
integer return_code=0

while [[ $i -lt $max ]]
do
    Java call statement;
    error_cnt=`grep -i exception $processing_file | wc -l`
    if (( $error_cnt != 0 ))
    then
        return_code=3;
        break
    # you don't need an else here, since continuing is the default
    fi
    (( i = i + 1 ))
done
# return with the code you specify
return $return_code

おすすめ記事