問題
当番では、Linuxでシェルスクリプトを積極的に使用する必要があります。
すべてのスクリプトは本質的に同じであるという事実にもかかわらず-データ生成。 顧客からの入力情報のチェックの正確性の記述とデバッグにかなりの時間がかかります。 そして、それに応じて、これらの入力パラメーターに基づくデータ生成パラメーターの決定。
チェックは、調整によって、多くの場合、テーブルによって定義される静的データに基づいています。調整の結果、新しい生成に必要な新しいパラメーターが形成されます。 同時に、エラーの可能性が高くなる可能性があるため、検証情報の設定作業には正確さと注意が必要です。
検証段階は、主にネストされたケースとifコンストラクトを積み上げることで構成されます。カットシステム(テーブル)を介してラベルを解析し、var1 var2 var3をifし、結果をどこかに形成するというアイデアがありました-しかし、これはあまり便利ではなく、最小限の構文のような美しい。
そして、長い間、「...ケアは霧の中心に置かれていました...」(Yesenin SA)が、最適化ソリューションはありませんでした。
決定は、いつものように、突然起こった。 シェルドックをもう一度掘り下げ、別の変数にある名前で変数にアクセスするというアイデアをスクロールします-「間接リンク」というトピックが見つかりました! おそらく、尊敬されているフォーラムのユーザーはそのようなシェル機能に精通していますが、知らない人のために、小さな説明例を示します:
間接変数参照
結果:
name_of_var = Var
val = var_value
新しいバージョンではval = var_value
そして、それは行きました
タスクの説明に美しい構文を作成し、それを適切に分析することを決定しました。
ほとんどの条件は入力値のテーブルに簡単に収まり、出力の依存関係もテーブルに著しく折りたたまれます。 さらに推論。 入力情報とそれに対応する1行の出力は優れています。 美しいセパレータが必要です。 区切り記号は、数学の次の「=>」記号によって作成され、ここでは、対応する出力パラメーターが入力パラメーターの1つのセットから続くように見えます。
構文:
集計による入力変数の名前
=>集計による出力変数の名前
集計による入力パラメータの値
=>対応する出力値の集計
おそらく、逆引用符で囲まれた計算式「[何かを計算する」」。
空行および「#」文字で始まる行は処理されません。
タブ区切り。
条件ブロックは特別な式で終了します
, => .
.
:
<?> - ; <_>- ; <.>- .
, , , .
, bash , . .
, .
, , , .
.
, . () , .
, , - () .
:
Speed= Sign= State=
, => .
.
:
<?> - ; <_>- ; <.>- .
, , , .
, bash , . .
, .
, , , .
.
, . () , .
, , - () .
:
Speed= Sign= State=
-
, => .
.
:
<?> - ; <_>- ; <.>- .
, , , .
, bash , . .
, .
, , , .
.
, . () , .
, , - () .
:
Speed= Sign= State=
, => .
.
:
<?> - ; <_>- ; <.>- .
, , , .
, bash , . .
, .
, , , .
.
, . () , .
, , - () .
:
Speed= Sign= State=
-
, => .
.
:
<?> - ; <_>- ; <.>- .
, , , .
, bash , . .
, .
, , , .
.
, . () , .
, , - () .
:
Speed= Sign= State=
, => .
.
:
<?> - ; <_>- ; <.>- .
, , , .
, bash , . .
, .
, , , .
.
, . () , .
, , - () .
:
Speed= Sign= State=
-
, => .
.
:
<?> - ; <_>- ; <.>- .
, , , .
, bash , . .
, .
, , , .
.
, . () , .
, , - () .
:
Speed= Sign= State=
, => .
.
:
<?> - ; <_>- ; <.>- .
, , , .
, bash , . .
, .
, , , .
.
, . () , .
, , - () .
:
Speed= Sign= State=
, => .
.
:
<?> - ; <_>- ; <.>- .
, , , .
, bash , . .
, .
, , , .
.
, . () , .
, , - () .
:
Speed= Sign= State=
, => .
.
:
<?> - ; <_>- ; <.>- .
, , , .
, bash , . .
, .
, , , .
.
, . () , .
, , - () .
:
Speed= Sign= State=
, => .
.
:
<?> - ; <_>- ; <.>- .
, , , .
, bash , . .
, .
, , , .
.
, . () , .
, , - () .
:
Speed= Sign= State=
次に、パラメーター値の正確性がチェックされます。
if elseコンストラクトが通常使用されるか、caseを使用できます。
if [[ "$Speed" == "" ]] || [[ "$Speed" == "" ]] || [[ "$Speed" == "" ]] then echo "Speed ok" else echo "Wrong Speed:${Speed}.";exit 0; fi
しかし、構文を観察し、補助変数Resultを導入する必要がありますが、私は新しい方法で気に入っています。
さらに、条件は次の2つで構成されます:Speedパラメーターの正確さを確認する
実際に必要なアクションを見つけるための主な条件:
Conditions=' # Speed => Result => OK => OK => OK <ERROR> echo "Wrong Speed:${Speed}.";exit 0; => Error # Sign State Speed => ToDo Speed => <?> => => => => => <?> => $Speed <ERROR> echo "Wrong traffic lights"; => $ToDo $Speed '
条件が形成され、CheckTabel.shハンドラーを実行して結果を表示します。
source $HOME/bin/CheckTabel.sh
結果:
Todo =スローダウンSpeed =スロー
サンプルTest.shの全文
結果:
Todo =スローダウンSpeed =スロー
代替案:
Todo =ブレーキSpeed =スタンド
ここでは、最初の条件の後にSpeed値が変更されているため、異なる結果が表示されます。
仕組み
ここで簡単に説明すると、CheckTabel.shの処理が行うこと、記事の最後にある全文です。
最初に、古いタブが保存され、新しいタブ区切り文字が設定されました。
次に、$ Conditionsから1行ずつ読み取り、文字列全体をLineに保存します。
echo "${Conditions}" | while read Line do … done
呼び出されたスクリプトからネストされたスクリプトで変数の値を簡単に取得できることは知りませんでしたが、これは後で役立ちます。
内部では、私の意見では、微妙な瞬間について説明します。
空行、コメントのある行、その他の不要な行はスキップします。
各行をタブで区切られたパラメーターに分割し、パラメーターを配列に入れます。 必要な行から、変数の名前を抽出します。 これは私のためにこのように行われます:
eVarLine=(`echo "$Line"`)
さらに興味深いことに、変数への間接参照を使用するサイクルでは、入力パラメーターeVarDatINの値の配列を形成します。
tmp=${eVarLine[$i]}
=>記号の後の変数名が出力されます。eVarOUT配列に保存します。
ループ内の値を持つ行から、変数の値を抽出し、eDatLine配列に書き込みます。
eDatLine=( `echo "$Line"` )
これらの値をeVarDatINに格納されている入力パラメーターの値と比較し、値がパターン(<?>、<。>、<_>)で一致する場合、配列にDataOUT値を入力します。
.
.
, – ? , , .
, , .
( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message
. , .
# ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setup vars
tmpSetVar.sh , Result="OK"
Result="OK"
ToDo=""
Speed=""
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong ramp police";
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong let have road";
ToDoAlter=""
SpeedAlter=""
. – .
, .
Perl - , .
.
CheckTabel.sh #/bin/ksh #/bin/bash # # script CheckTabel.sh - check tabel data # # See on : http://www.linuxcookbook.ru/books/absguide/ch09s05.html # #12.02.2013 _aap_ created by Patratskiy Aleksey #26.02.2013 _aap_ RELAEASE work with errors, get first right parametrs #28.02.2013 _aap_ fix same problem var counts #05.03.2013 _aap_ can use without <END> # #Limits : #Comment '#' work only for first position in string #Devior TAB If parameters use TAB it can not be used #input data: Conditions # # after you can check variable "CheckTabelErrors" for errors count #exaple of var :Conditions #Conditions=' ##check stuff of vars and data #Check var parametrs #varIn1 varIn2 varIn3 varIn4 => varOut1 varOut2 #varIn1varIn1 varIn2varIn2 varIn3varIn3 varIn4varIn4 => AAPvarOut1varOut1 AAPvarOut2varOut2 #<.> <_> <> dsf => sdf sdf #<ERROR> Error `exit 1` => <> <> #<END> #' #internals Vars: eTmpFile=$HOME/tmp/tmpSetVar.sh eDIVISOR=' ' eInOutDevisor='=>' eEND='<END>' eERROR='<ERROR>' eANY='<?>' eEMPTY='<_>' eNOTEMPTY='<.>' eISVAR=1 eDeb="" eIsFind=0 ((CheckTabelErrors=0)) ((eCurLine=0)) #for ksh typeset -A eDataIN typeset -A eDataOUT typeset -A eVarIN typeset -A eVarDatIN typeset -A eVarOUT typeset -A eVarLine typeset -A eDatLine #for bash #typeset -a eDataIN #typeset -a eDataOUT #typeset -a eVarIN #typeset -a eVarDatIN #typeset -a eVarOUT #typeset -a eVarLine #typeset -a eDatLine #source $eTmpFile # erase temporary file for setap vars > $eTmpFile # erase temporary file for setap vars #echo ifs=$IFS OLD_IFS="$IFS" IFS=$' '# echo "${Conditions}" | while read Line do ((eCurLine++)) # echo "LineErr: ${eCurLine}" ;echo "Line: ${Line}" if [[ "${Line:0:1}" != "#" && "$Line" != "" && "${Line:0:${#eEND}}" != "${eEND}" ]] #skeep empty and commets lines AND with <END> then if [[ "eISVAR" -eq "1" ]] # check for var names line then eISVAR=0 eVarLine=(`echo "$Line"`) cntIn=${#eVarLine[@]} # echo ${#eVarLine[@]} ${eVarLine[@]} for (( i = 0 ; i < cntIn ; i++ )) do #get names of input vars if [ "${eVarLine[${i}]}" == "${eInOutDevisor}" ] then ((outBgn=i + 1)) break fi eVarIN[${i}]=${eVarLine[$i]} tmp=${eVarLine[$i]} # get name of input var eval tmp=\$$tmp # gat var value by var name eVarDatIN[${i}]=${tmp} # echo DEBUG Element [$i]: ${eVarLine[$i]} val=${eVarIN[${i}]} eVarDatIN=${eVarDatIN[${i}]} done # echo DEBUG outBgn=$outBgn cntIn=$cntIn if (( cntIn == 0 || outBgn == 0 )) then echo !!! Error CheckTabel.sh formating outBgn=$outBgn cntIn=$cntIn wrong eDIVISOR TAB continue fi (( j = 0 )) for (( i = $outBgn ; i < cntIn ; i++ )) do # get name of output vars # echo "${eVarLine[$i]}=Set${i}" eVarOUT[$j]=${eVarLine[$i]} ((j++)) done eIsFind=0 # not finde yet # echo eVarIN ${#eVarIN[@]}: ${eVarIN[@]} ; echo eVarOUT ${#eVarOUT[@]}: ${eVarOUT[@]} ################################################################################### else if [[ "${Line:0:${#eEND}}" == "${eEND}" ]] # check for end of sentence then # echo "END: $Line" #echo "Line: ${Line:0:${#eEND}} == " # eISVAR=1 # source $eTmpFile #. data-file # execute file and set values for vars # > $eTmpFile # erase temporary file for setap vars continue # while read Line fi # #Check for error message and error vars set # if [[ "${Line:0:${#eERROR}}" == "${eERROR}" ]] # check for ERROR of sentence then # echo "<ERROR>:${eIsFind} $Line" #echo "Line: ${Line:0:${#eEND}} == " LineErr="" if [[ "eIsFind" -eq "0" ]] then ((CheckTabelErrors++)) LineErr="${Line#${eERROR}}" #remove <Error> echo "!!! ERROR CheckTabel.sh LineErr: ${eCurLine}" #;echo "Line: ${Line}" ErrVarOut="${LineErr#*${eInOutDevisor}}" #+ ${#eInOutDevisor}+ LineErr="${LineErr%${eInOutDevisor}*}" eDataOUT=( `echo "$ErrVarOut"` ) ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message fi # ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setap vars continue # while read Line fi #for skeep all next currient tabel parametrs if [[ "eIsFind" -eq "1" ]] then continue # while read Line fi eDatLine=( `echo "$Line"` ) # echo OUT ${#eDatLine[@]} ${eDatLine[@]} cntOut=${#eDatLine[@]} if (( $cntIn != $cntOut )) then echo !!! Error CheckTabel.sh in Conditions line=${eCurLine} formating Vars $cntIn but Data $cntOut, count of parametrs not equel ! ;echo !!! ${eVarIN[@]} === ${eDatLine[@]} continue # while read Line fi # # main check for compare tabale value and var value in currient string # ((cmpCnt=0)) for (( i = 0 ; i < cntOut ; i++ )) do #get input data if [ "${eDatLine[${i}]}" == "${eInOutDevisor}" ] ; then ((outBgn=i + 1)) break fi # echo DEBUG Element [$i]: ${eDatLine[$i]} val=${!eDatLine[$i]} eDatLine=${eDatLine[${i}]} == eVarDatIN="${eVarDatIN[$i]}" if [ "${eDatLine[${i}]}" == "${eVarDatIN[$i]}" ] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eANY}" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eNOTEMPTY}" && "${eVarDatIN[$i]}" != "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eEMPTY}" && "${eVarDatIN[$i]}" == "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi done # echo DEBUG "$cmpCnt" == "(($outBgn - 1 ))" outBgn=$outBgn cntIn=$cntIn if (( "$cmpCnt" == "(($outBgn - 1 ))" )) # there are data in this string #${#eVarIN[@]} then (( j = 0 )) for (( i = $outBgn ; i < cntOut ; i++ )) do # get value for output vars eDataOUT[$j]=${eDatLine[$i]} # echo "DEBUG ${eVarOUT[$j]}=${eDataOUT[$j]}" ((j++)) done ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done ) >> $eTmpFile # create temporary file for setap vars eIsFind=1 # echo OK: ${eVarIN[@]} == ${eDataIN[@]} '=>' ${eVarOUT[@]} == ${eDataOUT[@]} fi fi else #skeep empty and commets lines # echo Comment: $Line eDeb="" # for skeep warning fi done #while read Line ######################################################################3 IFS=$OLD_IFS #rm $eTmpFile
.
.
, – ? , , .
, , .
( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message
. , .
# ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setup vars
tmpSetVar.sh , Result="OK"
Result="OK"
ToDo=""
Speed=""
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong ramp police";
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong let have road";
ToDoAlter=""
SpeedAlter=""
. – .
, .
Perl - , .
.
CheckTabel.sh #/bin/ksh #/bin/bash # # script CheckTabel.sh - check tabel data # # See on : http://www.linuxcookbook.ru/books/absguide/ch09s05.html # #12.02.2013 _aap_ created by Patratskiy Aleksey #26.02.2013 _aap_ RELAEASE work with errors, get first right parametrs #28.02.2013 _aap_ fix same problem var counts #05.03.2013 _aap_ can use without <END> # #Limits : #Comment '#' work only for first position in string #Devior TAB If parameters use TAB it can not be used #input data: Conditions # # after you can check variable "CheckTabelErrors" for errors count #exaple of var :Conditions #Conditions=' ##check stuff of vars and data #Check var parametrs #varIn1 varIn2 varIn3 varIn4 => varOut1 varOut2 #varIn1varIn1 varIn2varIn2 varIn3varIn3 varIn4varIn4 => AAPvarOut1varOut1 AAPvarOut2varOut2 #<.> <_> <> dsf => sdf sdf #<ERROR> Error `exit 1` => <> <> #<END> #' #internals Vars: eTmpFile=$HOME/tmp/tmpSetVar.sh eDIVISOR=' ' eInOutDevisor='=>' eEND='<END>' eERROR='<ERROR>' eANY='<?>' eEMPTY='<_>' eNOTEMPTY='<.>' eISVAR=1 eDeb="" eIsFind=0 ((CheckTabelErrors=0)) ((eCurLine=0)) #for ksh typeset -A eDataIN typeset -A eDataOUT typeset -A eVarIN typeset -A eVarDatIN typeset -A eVarOUT typeset -A eVarLine typeset -A eDatLine #for bash #typeset -a eDataIN #typeset -a eDataOUT #typeset -a eVarIN #typeset -a eVarDatIN #typeset -a eVarOUT #typeset -a eVarLine #typeset -a eDatLine #source $eTmpFile # erase temporary file for setap vars > $eTmpFile # erase temporary file for setap vars #echo ifs=$IFS OLD_IFS="$IFS" IFS=$' '# echo "${Conditions}" | while read Line do ((eCurLine++)) # echo "LineErr: ${eCurLine}" ;echo "Line: ${Line}" if [[ "${Line:0:1}" != "#" && "$Line" != "" && "${Line:0:${#eEND}}" != "${eEND}" ]] #skeep empty and commets lines AND with <END> then if [[ "eISVAR" -eq "1" ]] # check for var names line then eISVAR=0 eVarLine=(`echo "$Line"`) cntIn=${#eVarLine[@]} # echo ${#eVarLine[@]} ${eVarLine[@]} for (( i = 0 ; i < cntIn ; i++ )) do #get names of input vars if [ "${eVarLine[${i}]}" == "${eInOutDevisor}" ] then ((outBgn=i + 1)) break fi eVarIN[${i}]=${eVarLine[$i]} tmp=${eVarLine[$i]} # get name of input var eval tmp=\$$tmp # gat var value by var name eVarDatIN[${i}]=${tmp} # echo DEBUG Element [$i]: ${eVarLine[$i]} val=${eVarIN[${i}]} eVarDatIN=${eVarDatIN[${i}]} done # echo DEBUG outBgn=$outBgn cntIn=$cntIn if (( cntIn == 0 || outBgn == 0 )) then echo !!! Error CheckTabel.sh formating outBgn=$outBgn cntIn=$cntIn wrong eDIVISOR TAB continue fi (( j = 0 )) for (( i = $outBgn ; i < cntIn ; i++ )) do # get name of output vars # echo "${eVarLine[$i]}=Set${i}" eVarOUT[$j]=${eVarLine[$i]} ((j++)) done eIsFind=0 # not finde yet # echo eVarIN ${#eVarIN[@]}: ${eVarIN[@]} ; echo eVarOUT ${#eVarOUT[@]}: ${eVarOUT[@]} ################################################################################### else if [[ "${Line:0:${#eEND}}" == "${eEND}" ]] # check for end of sentence then # echo "END: $Line" #echo "Line: ${Line:0:${#eEND}} == " # eISVAR=1 # source $eTmpFile #. data-file # execute file and set values for vars # > $eTmpFile # erase temporary file for setap vars continue # while read Line fi # #Check for error message and error vars set # if [[ "${Line:0:${#eERROR}}" == "${eERROR}" ]] # check for ERROR of sentence then # echo "<ERROR>:${eIsFind} $Line" #echo "Line: ${Line:0:${#eEND}} == " LineErr="" if [[ "eIsFind" -eq "0" ]] then ((CheckTabelErrors++)) LineErr="${Line#${eERROR}}" #remove <Error> echo "!!! ERROR CheckTabel.sh LineErr: ${eCurLine}" #;echo "Line: ${Line}" ErrVarOut="${LineErr#*${eInOutDevisor}}" #+ ${#eInOutDevisor}+ LineErr="${LineErr%${eInOutDevisor}*}" eDataOUT=( `echo "$ErrVarOut"` ) ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message fi # ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setap vars continue # while read Line fi #for skeep all next currient tabel parametrs if [[ "eIsFind" -eq "1" ]] then continue # while read Line fi eDatLine=( `echo "$Line"` ) # echo OUT ${#eDatLine[@]} ${eDatLine[@]} cntOut=${#eDatLine[@]} if (( $cntIn != $cntOut )) then echo !!! Error CheckTabel.sh in Conditions line=${eCurLine} formating Vars $cntIn but Data $cntOut, count of parametrs not equel ! ;echo !!! ${eVarIN[@]} === ${eDatLine[@]} continue # while read Line fi # # main check for compare tabale value and var value in currient string # ((cmpCnt=0)) for (( i = 0 ; i < cntOut ; i++ )) do #get input data if [ "${eDatLine[${i}]}" == "${eInOutDevisor}" ] ; then ((outBgn=i + 1)) break fi # echo DEBUG Element [$i]: ${eDatLine[$i]} val=${!eDatLine[$i]} eDatLine=${eDatLine[${i}]} == eVarDatIN="${eVarDatIN[$i]}" if [ "${eDatLine[${i}]}" == "${eVarDatIN[$i]}" ] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eANY}" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eNOTEMPTY}" && "${eVarDatIN[$i]}" != "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eEMPTY}" && "${eVarDatIN[$i]}" == "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi done # echo DEBUG "$cmpCnt" == "(($outBgn - 1 ))" outBgn=$outBgn cntIn=$cntIn if (( "$cmpCnt" == "(($outBgn - 1 ))" )) # there are data in this string #${#eVarIN[@]} then (( j = 0 )) for (( i = $outBgn ; i < cntOut ; i++ )) do # get value for output vars eDataOUT[$j]=${eDatLine[$i]} # echo "DEBUG ${eVarOUT[$j]}=${eDataOUT[$j]}" ((j++)) done ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done ) >> $eTmpFile # create temporary file for setap vars eIsFind=1 # echo OK: ${eVarIN[@]} == ${eDataIN[@]} '=>' ${eVarOUT[@]} == ${eDataOUT[@]} fi fi else #skeep empty and commets lines # echo Comment: $Line eDeb="" # for skeep warning fi done #while read Line ######################################################################3 IFS=$OLD_IFS #rm $eTmpFile
.
.
, – ? , , .
, , .
( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message
. , .
# ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setup vars
tmpSetVar.sh , Result="OK"
Result="OK"
ToDo=""
Speed=""
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong ramp police";
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong let have road";
ToDoAlter=""
SpeedAlter=""
. – .
, .
Perl - , .
.
CheckTabel.sh #/bin/ksh #/bin/bash # # script CheckTabel.sh - check tabel data # # See on : http://www.linuxcookbook.ru/books/absguide/ch09s05.html # #12.02.2013 _aap_ created by Patratskiy Aleksey #26.02.2013 _aap_ RELAEASE work with errors, get first right parametrs #28.02.2013 _aap_ fix same problem var counts #05.03.2013 _aap_ can use without <END> # #Limits : #Comment '#' work only for first position in string #Devior TAB If parameters use TAB it can not be used #input data: Conditions # # after you can check variable "CheckTabelErrors" for errors count #exaple of var :Conditions #Conditions=' ##check stuff of vars and data #Check var parametrs #varIn1 varIn2 varIn3 varIn4 => varOut1 varOut2 #varIn1varIn1 varIn2varIn2 varIn3varIn3 varIn4varIn4 => AAPvarOut1varOut1 AAPvarOut2varOut2 #<.> <_> <> dsf => sdf sdf #<ERROR> Error `exit 1` => <> <> #<END> #' #internals Vars: eTmpFile=$HOME/tmp/tmpSetVar.sh eDIVISOR=' ' eInOutDevisor='=>' eEND='<END>' eERROR='<ERROR>' eANY='<?>' eEMPTY='<_>' eNOTEMPTY='<.>' eISVAR=1 eDeb="" eIsFind=0 ((CheckTabelErrors=0)) ((eCurLine=0)) #for ksh typeset -A eDataIN typeset -A eDataOUT typeset -A eVarIN typeset -A eVarDatIN typeset -A eVarOUT typeset -A eVarLine typeset -A eDatLine #for bash #typeset -a eDataIN #typeset -a eDataOUT #typeset -a eVarIN #typeset -a eVarDatIN #typeset -a eVarOUT #typeset -a eVarLine #typeset -a eDatLine #source $eTmpFile # erase temporary file for setap vars > $eTmpFile # erase temporary file for setap vars #echo ifs=$IFS OLD_IFS="$IFS" IFS=$' '# echo "${Conditions}" | while read Line do ((eCurLine++)) # echo "LineErr: ${eCurLine}" ;echo "Line: ${Line}" if [[ "${Line:0:1}" != "#" && "$Line" != "" && "${Line:0:${#eEND}}" != "${eEND}" ]] #skeep empty and commets lines AND with <END> then if [[ "eISVAR" -eq "1" ]] # check for var names line then eISVAR=0 eVarLine=(`echo "$Line"`) cntIn=${#eVarLine[@]} # echo ${#eVarLine[@]} ${eVarLine[@]} for (( i = 0 ; i < cntIn ; i++ )) do #get names of input vars if [ "${eVarLine[${i}]}" == "${eInOutDevisor}" ] then ((outBgn=i + 1)) break fi eVarIN[${i}]=${eVarLine[$i]} tmp=${eVarLine[$i]} # get name of input var eval tmp=\$$tmp # gat var value by var name eVarDatIN[${i}]=${tmp} # echo DEBUG Element [$i]: ${eVarLine[$i]} val=${eVarIN[${i}]} eVarDatIN=${eVarDatIN[${i}]} done # echo DEBUG outBgn=$outBgn cntIn=$cntIn if (( cntIn == 0 || outBgn == 0 )) then echo !!! Error CheckTabel.sh formating outBgn=$outBgn cntIn=$cntIn wrong eDIVISOR TAB continue fi (( j = 0 )) for (( i = $outBgn ; i < cntIn ; i++ )) do # get name of output vars # echo "${eVarLine[$i]}=Set${i}" eVarOUT[$j]=${eVarLine[$i]} ((j++)) done eIsFind=0 # not finde yet # echo eVarIN ${#eVarIN[@]}: ${eVarIN[@]} ; echo eVarOUT ${#eVarOUT[@]}: ${eVarOUT[@]} ################################################################################### else if [[ "${Line:0:${#eEND}}" == "${eEND}" ]] # check for end of sentence then # echo "END: $Line" #echo "Line: ${Line:0:${#eEND}} == " # eISVAR=1 # source $eTmpFile #. data-file # execute file and set values for vars # > $eTmpFile # erase temporary file for setap vars continue # while read Line fi # #Check for error message and error vars set # if [[ "${Line:0:${#eERROR}}" == "${eERROR}" ]] # check for ERROR of sentence then # echo "<ERROR>:${eIsFind} $Line" #echo "Line: ${Line:0:${#eEND}} == " LineErr="" if [[ "eIsFind" -eq "0" ]] then ((CheckTabelErrors++)) LineErr="${Line#${eERROR}}" #remove <Error> echo "!!! ERROR CheckTabel.sh LineErr: ${eCurLine}" #;echo "Line: ${Line}" ErrVarOut="${LineErr#*${eInOutDevisor}}" #+ ${#eInOutDevisor}+ LineErr="${LineErr%${eInOutDevisor}*}" eDataOUT=( `echo "$ErrVarOut"` ) ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message fi # ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setap vars continue # while read Line fi #for skeep all next currient tabel parametrs if [[ "eIsFind" -eq "1" ]] then continue # while read Line fi eDatLine=( `echo "$Line"` ) # echo OUT ${#eDatLine[@]} ${eDatLine[@]} cntOut=${#eDatLine[@]} if (( $cntIn != $cntOut )) then echo !!! Error CheckTabel.sh in Conditions line=${eCurLine} formating Vars $cntIn but Data $cntOut, count of parametrs not equel ! ;echo !!! ${eVarIN[@]} === ${eDatLine[@]} continue # while read Line fi # # main check for compare tabale value and var value in currient string # ((cmpCnt=0)) for (( i = 0 ; i < cntOut ; i++ )) do #get input data if [ "${eDatLine[${i}]}" == "${eInOutDevisor}" ] ; then ((outBgn=i + 1)) break fi # echo DEBUG Element [$i]: ${eDatLine[$i]} val=${!eDatLine[$i]} eDatLine=${eDatLine[${i}]} == eVarDatIN="${eVarDatIN[$i]}" if [ "${eDatLine[${i}]}" == "${eVarDatIN[$i]}" ] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eANY}" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eNOTEMPTY}" && "${eVarDatIN[$i]}" != "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eEMPTY}" && "${eVarDatIN[$i]}" == "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi done # echo DEBUG "$cmpCnt" == "(($outBgn - 1 ))" outBgn=$outBgn cntIn=$cntIn if (( "$cmpCnt" == "(($outBgn - 1 ))" )) # there are data in this string #${#eVarIN[@]} then (( j = 0 )) for (( i = $outBgn ; i < cntOut ; i++ )) do # get value for output vars eDataOUT[$j]=${eDatLine[$i]} # echo "DEBUG ${eVarOUT[$j]}=${eDataOUT[$j]}" ((j++)) done ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done ) >> $eTmpFile # create temporary file for setap vars eIsFind=1 # echo OK: ${eVarIN[@]} == ${eDataIN[@]} '=>' ${eVarOUT[@]} == ${eDataOUT[@]} fi fi else #skeep empty and commets lines # echo Comment: $Line eDeb="" # for skeep warning fi done #while read Line ######################################################################3 IFS=$OLD_IFS #rm $eTmpFile
.
.
, – ? , , .
, , .
( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message
. , .
# ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setup vars
tmpSetVar.sh , Result="OK"
Result="OK"
ToDo=""
Speed=""
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong ramp police";
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong let have road";
ToDoAlter=""
SpeedAlter=""
. – .
, .
Perl - , .
.
CheckTabel.sh #/bin/ksh #/bin/bash # # script CheckTabel.sh - check tabel data # # See on : http://www.linuxcookbook.ru/books/absguide/ch09s05.html # #12.02.2013 _aap_ created by Patratskiy Aleksey #26.02.2013 _aap_ RELAEASE work with errors, get first right parametrs #28.02.2013 _aap_ fix same problem var counts #05.03.2013 _aap_ can use without <END> # #Limits : #Comment '#' work only for first position in string #Devior TAB If parameters use TAB it can not be used #input data: Conditions # # after you can check variable "CheckTabelErrors" for errors count #exaple of var :Conditions #Conditions=' ##check stuff of vars and data #Check var parametrs #varIn1 varIn2 varIn3 varIn4 => varOut1 varOut2 #varIn1varIn1 varIn2varIn2 varIn3varIn3 varIn4varIn4 => AAPvarOut1varOut1 AAPvarOut2varOut2 #<.> <_> <> dsf => sdf sdf #<ERROR> Error `exit 1` => <> <> #<END> #' #internals Vars: eTmpFile=$HOME/tmp/tmpSetVar.sh eDIVISOR=' ' eInOutDevisor='=>' eEND='<END>' eERROR='<ERROR>' eANY='<?>' eEMPTY='<_>' eNOTEMPTY='<.>' eISVAR=1 eDeb="" eIsFind=0 ((CheckTabelErrors=0)) ((eCurLine=0)) #for ksh typeset -A eDataIN typeset -A eDataOUT typeset -A eVarIN typeset -A eVarDatIN typeset -A eVarOUT typeset -A eVarLine typeset -A eDatLine #for bash #typeset -a eDataIN #typeset -a eDataOUT #typeset -a eVarIN #typeset -a eVarDatIN #typeset -a eVarOUT #typeset -a eVarLine #typeset -a eDatLine #source $eTmpFile # erase temporary file for setap vars > $eTmpFile # erase temporary file for setap vars #echo ifs=$IFS OLD_IFS="$IFS" IFS=$' '# echo "${Conditions}" | while read Line do ((eCurLine++)) # echo "LineErr: ${eCurLine}" ;echo "Line: ${Line}" if [[ "${Line:0:1}" != "#" && "$Line" != "" && "${Line:0:${#eEND}}" != "${eEND}" ]] #skeep empty and commets lines AND with <END> then if [[ "eISVAR" -eq "1" ]] # check for var names line then eISVAR=0 eVarLine=(`echo "$Line"`) cntIn=${#eVarLine[@]} # echo ${#eVarLine[@]} ${eVarLine[@]} for (( i = 0 ; i < cntIn ; i++ )) do #get names of input vars if [ "${eVarLine[${i}]}" == "${eInOutDevisor}" ] then ((outBgn=i + 1)) break fi eVarIN[${i}]=${eVarLine[$i]} tmp=${eVarLine[$i]} # get name of input var eval tmp=\$$tmp # gat var value by var name eVarDatIN[${i}]=${tmp} # echo DEBUG Element [$i]: ${eVarLine[$i]} val=${eVarIN[${i}]} eVarDatIN=${eVarDatIN[${i}]} done # echo DEBUG outBgn=$outBgn cntIn=$cntIn if (( cntIn == 0 || outBgn == 0 )) then echo !!! Error CheckTabel.sh formating outBgn=$outBgn cntIn=$cntIn wrong eDIVISOR TAB continue fi (( j = 0 )) for (( i = $outBgn ; i < cntIn ; i++ )) do # get name of output vars # echo "${eVarLine[$i]}=Set${i}" eVarOUT[$j]=${eVarLine[$i]} ((j++)) done eIsFind=0 # not finde yet # echo eVarIN ${#eVarIN[@]}: ${eVarIN[@]} ; echo eVarOUT ${#eVarOUT[@]}: ${eVarOUT[@]} ################################################################################### else if [[ "${Line:0:${#eEND}}" == "${eEND}" ]] # check for end of sentence then # echo "END: $Line" #echo "Line: ${Line:0:${#eEND}} == " # eISVAR=1 # source $eTmpFile #. data-file # execute file and set values for vars # > $eTmpFile # erase temporary file for setap vars continue # while read Line fi # #Check for error message and error vars set # if [[ "${Line:0:${#eERROR}}" == "${eERROR}" ]] # check for ERROR of sentence then # echo "<ERROR>:${eIsFind} $Line" #echo "Line: ${Line:0:${#eEND}} == " LineErr="" if [[ "eIsFind" -eq "0" ]] then ((CheckTabelErrors++)) LineErr="${Line#${eERROR}}" #remove <Error> echo "!!! ERROR CheckTabel.sh LineErr: ${eCurLine}" #;echo "Line: ${Line}" ErrVarOut="${LineErr#*${eInOutDevisor}}" #+ ${#eInOutDevisor}+ LineErr="${LineErr%${eInOutDevisor}*}" eDataOUT=( `echo "$ErrVarOut"` ) ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message fi # ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setap vars continue # while read Line fi #for skeep all next currient tabel parametrs if [[ "eIsFind" -eq "1" ]] then continue # while read Line fi eDatLine=( `echo "$Line"` ) # echo OUT ${#eDatLine[@]} ${eDatLine[@]} cntOut=${#eDatLine[@]} if (( $cntIn != $cntOut )) then echo !!! Error CheckTabel.sh in Conditions line=${eCurLine} formating Vars $cntIn but Data $cntOut, count of parametrs not equel ! ;echo !!! ${eVarIN[@]} === ${eDatLine[@]} continue # while read Line fi # # main check for compare tabale value and var value in currient string # ((cmpCnt=0)) for (( i = 0 ; i < cntOut ; i++ )) do #get input data if [ "${eDatLine[${i}]}" == "${eInOutDevisor}" ] ; then ((outBgn=i + 1)) break fi # echo DEBUG Element [$i]: ${eDatLine[$i]} val=${!eDatLine[$i]} eDatLine=${eDatLine[${i}]} == eVarDatIN="${eVarDatIN[$i]}" if [ "${eDatLine[${i}]}" == "${eVarDatIN[$i]}" ] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eANY}" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eNOTEMPTY}" && "${eVarDatIN[$i]}" != "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eEMPTY}" && "${eVarDatIN[$i]}" == "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi done # echo DEBUG "$cmpCnt" == "(($outBgn - 1 ))" outBgn=$outBgn cntIn=$cntIn if (( "$cmpCnt" == "(($outBgn - 1 ))" )) # there are data in this string #${#eVarIN[@]} then (( j = 0 )) for (( i = $outBgn ; i < cntOut ; i++ )) do # get value for output vars eDataOUT[$j]=${eDatLine[$i]} # echo "DEBUG ${eVarOUT[$j]}=${eDataOUT[$j]}" ((j++)) done ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done ) >> $eTmpFile # create temporary file for setap vars eIsFind=1 # echo OK: ${eVarIN[@]} == ${eDataIN[@]} '=>' ${eVarOUT[@]} == ${eDataOUT[@]} fi fi else #skeep empty and commets lines # echo Comment: $Line eDeb="" # for skeep warning fi done #while read Line ######################################################################3 IFS=$OLD_IFS #rm $eTmpFile
.
.
, – ? , , .
, , .
( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message
. , .
# ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setup vars
tmpSetVar.sh , Result="OK"
Result="OK"
ToDo=""
Speed=""
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong ramp police";
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong let have road";
ToDoAlter=""
SpeedAlter=""
. – .
, .
Perl - , .
.
CheckTabel.sh #/bin/ksh #/bin/bash # # script CheckTabel.sh - check tabel data # # See on : http://www.linuxcookbook.ru/books/absguide/ch09s05.html # #12.02.2013 _aap_ created by Patratskiy Aleksey #26.02.2013 _aap_ RELAEASE work with errors, get first right parametrs #28.02.2013 _aap_ fix same problem var counts #05.03.2013 _aap_ can use without <END> # #Limits : #Comment '#' work only for first position in string #Devior TAB If parameters use TAB it can not be used #input data: Conditions # # after you can check variable "CheckTabelErrors" for errors count #exaple of var :Conditions #Conditions=' ##check stuff of vars and data #Check var parametrs #varIn1 varIn2 varIn3 varIn4 => varOut1 varOut2 #varIn1varIn1 varIn2varIn2 varIn3varIn3 varIn4varIn4 => AAPvarOut1varOut1 AAPvarOut2varOut2 #<.> <_> <> dsf => sdf sdf #<ERROR> Error `exit 1` => <> <> #<END> #' #internals Vars: eTmpFile=$HOME/tmp/tmpSetVar.sh eDIVISOR=' ' eInOutDevisor='=>' eEND='<END>' eERROR='<ERROR>' eANY='<?>' eEMPTY='<_>' eNOTEMPTY='<.>' eISVAR=1 eDeb="" eIsFind=0 ((CheckTabelErrors=0)) ((eCurLine=0)) #for ksh typeset -A eDataIN typeset -A eDataOUT typeset -A eVarIN typeset -A eVarDatIN typeset -A eVarOUT typeset -A eVarLine typeset -A eDatLine #for bash #typeset -a eDataIN #typeset -a eDataOUT #typeset -a eVarIN #typeset -a eVarDatIN #typeset -a eVarOUT #typeset -a eVarLine #typeset -a eDatLine #source $eTmpFile # erase temporary file for setap vars > $eTmpFile # erase temporary file for setap vars #echo ifs=$IFS OLD_IFS="$IFS" IFS=$' '# echo "${Conditions}" | while read Line do ((eCurLine++)) # echo "LineErr: ${eCurLine}" ;echo "Line: ${Line}" if [[ "${Line:0:1}" != "#" && "$Line" != "" && "${Line:0:${#eEND}}" != "${eEND}" ]] #skeep empty and commets lines AND with <END> then if [[ "eISVAR" -eq "1" ]] # check for var names line then eISVAR=0 eVarLine=(`echo "$Line"`) cntIn=${#eVarLine[@]} # echo ${#eVarLine[@]} ${eVarLine[@]} for (( i = 0 ; i < cntIn ; i++ )) do #get names of input vars if [ "${eVarLine[${i}]}" == "${eInOutDevisor}" ] then ((outBgn=i + 1)) break fi eVarIN[${i}]=${eVarLine[$i]} tmp=${eVarLine[$i]} # get name of input var eval tmp=\$$tmp # gat var value by var name eVarDatIN[${i}]=${tmp} # echo DEBUG Element [$i]: ${eVarLine[$i]} val=${eVarIN[${i}]} eVarDatIN=${eVarDatIN[${i}]} done # echo DEBUG outBgn=$outBgn cntIn=$cntIn if (( cntIn == 0 || outBgn == 0 )) then echo !!! Error CheckTabel.sh formating outBgn=$outBgn cntIn=$cntIn wrong eDIVISOR TAB continue fi (( j = 0 )) for (( i = $outBgn ; i < cntIn ; i++ )) do # get name of output vars # echo "${eVarLine[$i]}=Set${i}" eVarOUT[$j]=${eVarLine[$i]} ((j++)) done eIsFind=0 # not finde yet # echo eVarIN ${#eVarIN[@]}: ${eVarIN[@]} ; echo eVarOUT ${#eVarOUT[@]}: ${eVarOUT[@]} ################################################################################### else if [[ "${Line:0:${#eEND}}" == "${eEND}" ]] # check for end of sentence then # echo "END: $Line" #echo "Line: ${Line:0:${#eEND}} == " # eISVAR=1 # source $eTmpFile #. data-file # execute file and set values for vars # > $eTmpFile # erase temporary file for setap vars continue # while read Line fi # #Check for error message and error vars set # if [[ "${Line:0:${#eERROR}}" == "${eERROR}" ]] # check for ERROR of sentence then # echo "<ERROR>:${eIsFind} $Line" #echo "Line: ${Line:0:${#eEND}} == " LineErr="" if [[ "eIsFind" -eq "0" ]] then ((CheckTabelErrors++)) LineErr="${Line#${eERROR}}" #remove <Error> echo "!!! ERROR CheckTabel.sh LineErr: ${eCurLine}" #;echo "Line: ${Line}" ErrVarOut="${LineErr#*${eInOutDevisor}}" #+ ${#eInOutDevisor}+ LineErr="${LineErr%${eInOutDevisor}*}" eDataOUT=( `echo "$ErrVarOut"` ) ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message fi # ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setap vars continue # while read Line fi #for skeep all next currient tabel parametrs if [[ "eIsFind" -eq "1" ]] then continue # while read Line fi eDatLine=( `echo "$Line"` ) # echo OUT ${#eDatLine[@]} ${eDatLine[@]} cntOut=${#eDatLine[@]} if (( $cntIn != $cntOut )) then echo !!! Error CheckTabel.sh in Conditions line=${eCurLine} formating Vars $cntIn but Data $cntOut, count of parametrs not equel ! ;echo !!! ${eVarIN[@]} === ${eDatLine[@]} continue # while read Line fi # # main check for compare tabale value and var value in currient string # ((cmpCnt=0)) for (( i = 0 ; i < cntOut ; i++ )) do #get input data if [ "${eDatLine[${i}]}" == "${eInOutDevisor}" ] ; then ((outBgn=i + 1)) break fi # echo DEBUG Element [$i]: ${eDatLine[$i]} val=${!eDatLine[$i]} eDatLine=${eDatLine[${i}]} == eVarDatIN="${eVarDatIN[$i]}" if [ "${eDatLine[${i}]}" == "${eVarDatIN[$i]}" ] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eANY}" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eNOTEMPTY}" && "${eVarDatIN[$i]}" != "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eEMPTY}" && "${eVarDatIN[$i]}" == "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi done # echo DEBUG "$cmpCnt" == "(($outBgn - 1 ))" outBgn=$outBgn cntIn=$cntIn if (( "$cmpCnt" == "(($outBgn - 1 ))" )) # there are data in this string #${#eVarIN[@]} then (( j = 0 )) for (( i = $outBgn ; i < cntOut ; i++ )) do # get value for output vars eDataOUT[$j]=${eDatLine[$i]} # echo "DEBUG ${eVarOUT[$j]}=${eDataOUT[$j]}" ((j++)) done ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done ) >> $eTmpFile # create temporary file for setap vars eIsFind=1 # echo OK: ${eVarIN[@]} == ${eDataIN[@]} '=>' ${eVarOUT[@]} == ${eDataOUT[@]} fi fi else #skeep empty and commets lines # echo Comment: $Line eDeb="" # for skeep warning fi done #while read Line ######################################################################3 IFS=$OLD_IFS #rm $eTmpFile
.
.
, – ? , , .
, , .
( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message
. , .
# ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setup vars
tmpSetVar.sh , Result="OK"
Result="OK"
ToDo=""
Speed=""
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong ramp police";
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong let have road";
ToDoAlter=""
SpeedAlter=""
. – .
, .
Perl - , .
.
CheckTabel.sh #/bin/ksh #/bin/bash # # script CheckTabel.sh - check tabel data # # See on : http://www.linuxcookbook.ru/books/absguide/ch09s05.html # #12.02.2013 _aap_ created by Patratskiy Aleksey #26.02.2013 _aap_ RELAEASE work with errors, get first right parametrs #28.02.2013 _aap_ fix same problem var counts #05.03.2013 _aap_ can use without <END> # #Limits : #Comment '#' work only for first position in string #Devior TAB If parameters use TAB it can not be used #input data: Conditions # # after you can check variable "CheckTabelErrors" for errors count #exaple of var :Conditions #Conditions=' ##check stuff of vars and data #Check var parametrs #varIn1 varIn2 varIn3 varIn4 => varOut1 varOut2 #varIn1varIn1 varIn2varIn2 varIn3varIn3 varIn4varIn4 => AAPvarOut1varOut1 AAPvarOut2varOut2 #<.> <_> <> dsf => sdf sdf #<ERROR> Error `exit 1` => <> <> #<END> #' #internals Vars: eTmpFile=$HOME/tmp/tmpSetVar.sh eDIVISOR=' ' eInOutDevisor='=>' eEND='<END>' eERROR='<ERROR>' eANY='<?>' eEMPTY='<_>' eNOTEMPTY='<.>' eISVAR=1 eDeb="" eIsFind=0 ((CheckTabelErrors=0)) ((eCurLine=0)) #for ksh typeset -A eDataIN typeset -A eDataOUT typeset -A eVarIN typeset -A eVarDatIN typeset -A eVarOUT typeset -A eVarLine typeset -A eDatLine #for bash #typeset -a eDataIN #typeset -a eDataOUT #typeset -a eVarIN #typeset -a eVarDatIN #typeset -a eVarOUT #typeset -a eVarLine #typeset -a eDatLine #source $eTmpFile # erase temporary file for setap vars > $eTmpFile # erase temporary file for setap vars #echo ifs=$IFS OLD_IFS="$IFS" IFS=$' '# echo "${Conditions}" | while read Line do ((eCurLine++)) # echo "LineErr: ${eCurLine}" ;echo "Line: ${Line}" if [[ "${Line:0:1}" != "#" && "$Line" != "" && "${Line:0:${#eEND}}" != "${eEND}" ]] #skeep empty and commets lines AND with <END> then if [[ "eISVAR" -eq "1" ]] # check for var names line then eISVAR=0 eVarLine=(`echo "$Line"`) cntIn=${#eVarLine[@]} # echo ${#eVarLine[@]} ${eVarLine[@]} for (( i = 0 ; i < cntIn ; i++ )) do #get names of input vars if [ "${eVarLine[${i}]}" == "${eInOutDevisor}" ] then ((outBgn=i + 1)) break fi eVarIN[${i}]=${eVarLine[$i]} tmp=${eVarLine[$i]} # get name of input var eval tmp=\$$tmp # gat var value by var name eVarDatIN[${i}]=${tmp} # echo DEBUG Element [$i]: ${eVarLine[$i]} val=${eVarIN[${i}]} eVarDatIN=${eVarDatIN[${i}]} done # echo DEBUG outBgn=$outBgn cntIn=$cntIn if (( cntIn == 0 || outBgn == 0 )) then echo !!! Error CheckTabel.sh formating outBgn=$outBgn cntIn=$cntIn wrong eDIVISOR TAB continue fi (( j = 0 )) for (( i = $outBgn ; i < cntIn ; i++ )) do # get name of output vars # echo "${eVarLine[$i]}=Set${i}" eVarOUT[$j]=${eVarLine[$i]} ((j++)) done eIsFind=0 # not finde yet # echo eVarIN ${#eVarIN[@]}: ${eVarIN[@]} ; echo eVarOUT ${#eVarOUT[@]}: ${eVarOUT[@]} ################################################################################### else if [[ "${Line:0:${#eEND}}" == "${eEND}" ]] # check for end of sentence then # echo "END: $Line" #echo "Line: ${Line:0:${#eEND}} == " # eISVAR=1 # source $eTmpFile #. data-file # execute file and set values for vars # > $eTmpFile # erase temporary file for setap vars continue # while read Line fi # #Check for error message and error vars set # if [[ "${Line:0:${#eERROR}}" == "${eERROR}" ]] # check for ERROR of sentence then # echo "<ERROR>:${eIsFind} $Line" #echo "Line: ${Line:0:${#eEND}} == " LineErr="" if [[ "eIsFind" -eq "0" ]] then ((CheckTabelErrors++)) LineErr="${Line#${eERROR}}" #remove <Error> echo "!!! ERROR CheckTabel.sh LineErr: ${eCurLine}" #;echo "Line: ${Line}" ErrVarOut="${LineErr#*${eInOutDevisor}}" #+ ${#eInOutDevisor}+ LineErr="${LineErr%${eInOutDevisor}*}" eDataOUT=( `echo "$ErrVarOut"` ) ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message fi # ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setap vars continue # while read Line fi #for skeep all next currient tabel parametrs if [[ "eIsFind" -eq "1" ]] then continue # while read Line fi eDatLine=( `echo "$Line"` ) # echo OUT ${#eDatLine[@]} ${eDatLine[@]} cntOut=${#eDatLine[@]} if (( $cntIn != $cntOut )) then echo !!! Error CheckTabel.sh in Conditions line=${eCurLine} formating Vars $cntIn but Data $cntOut, count of parametrs not equel ! ;echo !!! ${eVarIN[@]} === ${eDatLine[@]} continue # while read Line fi # # main check for compare tabale value and var value in currient string # ((cmpCnt=0)) for (( i = 0 ; i < cntOut ; i++ )) do #get input data if [ "${eDatLine[${i}]}" == "${eInOutDevisor}" ] ; then ((outBgn=i + 1)) break fi # echo DEBUG Element [$i]: ${eDatLine[$i]} val=${!eDatLine[$i]} eDatLine=${eDatLine[${i}]} == eVarDatIN="${eVarDatIN[$i]}" if [ "${eDatLine[${i}]}" == "${eVarDatIN[$i]}" ] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eANY}" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eNOTEMPTY}" && "${eVarDatIN[$i]}" != "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eEMPTY}" && "${eVarDatIN[$i]}" == "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi done # echo DEBUG "$cmpCnt" == "(($outBgn - 1 ))" outBgn=$outBgn cntIn=$cntIn if (( "$cmpCnt" == "(($outBgn - 1 ))" )) # there are data in this string #${#eVarIN[@]} then (( j = 0 )) for (( i = $outBgn ; i < cntOut ; i++ )) do # get value for output vars eDataOUT[$j]=${eDatLine[$i]} # echo "DEBUG ${eVarOUT[$j]}=${eDataOUT[$j]}" ((j++)) done ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done ) >> $eTmpFile # create temporary file for setap vars eIsFind=1 # echo OK: ${eVarIN[@]} == ${eDataIN[@]} '=>' ${eVarOUT[@]} == ${eDataOUT[@]} fi fi else #skeep empty and commets lines # echo Comment: $Line eDeb="" # for skeep warning fi done #while read Line ######################################################################3 IFS=$OLD_IFS #rm $eTmpFile
.
.
, – ? , , .
, , .
( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message
. , .
# ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setup vars
tmpSetVar.sh , Result="OK"
Result="OK"
ToDo=""
Speed=""
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong ramp police";
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong let have road";
ToDoAlter=""
SpeedAlter=""
. – .
, .
Perl - , .
.
CheckTabel.sh #/bin/ksh #/bin/bash # # script CheckTabel.sh - check tabel data # # See on : http://www.linuxcookbook.ru/books/absguide/ch09s05.html # #12.02.2013 _aap_ created by Patratskiy Aleksey #26.02.2013 _aap_ RELAEASE work with errors, get first right parametrs #28.02.2013 _aap_ fix same problem var counts #05.03.2013 _aap_ can use without <END> # #Limits : #Comment '#' work only for first position in string #Devior TAB If parameters use TAB it can not be used #input data: Conditions # # after you can check variable "CheckTabelErrors" for errors count #exaple of var :Conditions #Conditions=' ##check stuff of vars and data #Check var parametrs #varIn1 varIn2 varIn3 varIn4 => varOut1 varOut2 #varIn1varIn1 varIn2varIn2 varIn3varIn3 varIn4varIn4 => AAPvarOut1varOut1 AAPvarOut2varOut2 #<.> <_> <> dsf => sdf sdf #<ERROR> Error `exit 1` => <> <> #<END> #' #internals Vars: eTmpFile=$HOME/tmp/tmpSetVar.sh eDIVISOR=' ' eInOutDevisor='=>' eEND='<END>' eERROR='<ERROR>' eANY='<?>' eEMPTY='<_>' eNOTEMPTY='<.>' eISVAR=1 eDeb="" eIsFind=0 ((CheckTabelErrors=0)) ((eCurLine=0)) #for ksh typeset -A eDataIN typeset -A eDataOUT typeset -A eVarIN typeset -A eVarDatIN typeset -A eVarOUT typeset -A eVarLine typeset -A eDatLine #for bash #typeset -a eDataIN #typeset -a eDataOUT #typeset -a eVarIN #typeset -a eVarDatIN #typeset -a eVarOUT #typeset -a eVarLine #typeset -a eDatLine #source $eTmpFile # erase temporary file for setap vars > $eTmpFile # erase temporary file for setap vars #echo ifs=$IFS OLD_IFS="$IFS" IFS=$' '# echo "${Conditions}" | while read Line do ((eCurLine++)) # echo "LineErr: ${eCurLine}" ;echo "Line: ${Line}" if [[ "${Line:0:1}" != "#" && "$Line" != "" && "${Line:0:${#eEND}}" != "${eEND}" ]] #skeep empty and commets lines AND with <END> then if [[ "eISVAR" -eq "1" ]] # check for var names line then eISVAR=0 eVarLine=(`echo "$Line"`) cntIn=${#eVarLine[@]} # echo ${#eVarLine[@]} ${eVarLine[@]} for (( i = 0 ; i < cntIn ; i++ )) do #get names of input vars if [ "${eVarLine[${i}]}" == "${eInOutDevisor}" ] then ((outBgn=i + 1)) break fi eVarIN[${i}]=${eVarLine[$i]} tmp=${eVarLine[$i]} # get name of input var eval tmp=\$$tmp # gat var value by var name eVarDatIN[${i}]=${tmp} # echo DEBUG Element [$i]: ${eVarLine[$i]} val=${eVarIN[${i}]} eVarDatIN=${eVarDatIN[${i}]} done # echo DEBUG outBgn=$outBgn cntIn=$cntIn if (( cntIn == 0 || outBgn == 0 )) then echo !!! Error CheckTabel.sh formating outBgn=$outBgn cntIn=$cntIn wrong eDIVISOR TAB continue fi (( j = 0 )) for (( i = $outBgn ; i < cntIn ; i++ )) do # get name of output vars # echo "${eVarLine[$i]}=Set${i}" eVarOUT[$j]=${eVarLine[$i]} ((j++)) done eIsFind=0 # not finde yet # echo eVarIN ${#eVarIN[@]}: ${eVarIN[@]} ; echo eVarOUT ${#eVarOUT[@]}: ${eVarOUT[@]} ################################################################################### else if [[ "${Line:0:${#eEND}}" == "${eEND}" ]] # check for end of sentence then # echo "END: $Line" #echo "Line: ${Line:0:${#eEND}} == " # eISVAR=1 # source $eTmpFile #. data-file # execute file and set values for vars # > $eTmpFile # erase temporary file for setap vars continue # while read Line fi # #Check for error message and error vars set # if [[ "${Line:0:${#eERROR}}" == "${eERROR}" ]] # check for ERROR of sentence then # echo "<ERROR>:${eIsFind} $Line" #echo "Line: ${Line:0:${#eEND}} == " LineErr="" if [[ "eIsFind" -eq "0" ]] then ((CheckTabelErrors++)) LineErr="${Line#${eERROR}}" #remove <Error> echo "!!! ERROR CheckTabel.sh LineErr: ${eCurLine}" #;echo "Line: ${Line}" ErrVarOut="${LineErr#*${eInOutDevisor}}" #+ ${#eInOutDevisor}+ LineErr="${LineErr%${eInOutDevisor}*}" eDataOUT=( `echo "$ErrVarOut"` ) ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message fi # ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setap vars continue # while read Line fi #for skeep all next currient tabel parametrs if [[ "eIsFind" -eq "1" ]] then continue # while read Line fi eDatLine=( `echo "$Line"` ) # echo OUT ${#eDatLine[@]} ${eDatLine[@]} cntOut=${#eDatLine[@]} if (( $cntIn != $cntOut )) then echo !!! Error CheckTabel.sh in Conditions line=${eCurLine} formating Vars $cntIn but Data $cntOut, count of parametrs not equel ! ;echo !!! ${eVarIN[@]} === ${eDatLine[@]} continue # while read Line fi # # main check for compare tabale value and var value in currient string # ((cmpCnt=0)) for (( i = 0 ; i < cntOut ; i++ )) do #get input data if [ "${eDatLine[${i}]}" == "${eInOutDevisor}" ] ; then ((outBgn=i + 1)) break fi # echo DEBUG Element [$i]: ${eDatLine[$i]} val=${!eDatLine[$i]} eDatLine=${eDatLine[${i}]} == eVarDatIN="${eVarDatIN[$i]}" if [ "${eDatLine[${i}]}" == "${eVarDatIN[$i]}" ] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eANY}" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eNOTEMPTY}" && "${eVarDatIN[$i]}" != "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eEMPTY}" && "${eVarDatIN[$i]}" == "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi done # echo DEBUG "$cmpCnt" == "(($outBgn - 1 ))" outBgn=$outBgn cntIn=$cntIn if (( "$cmpCnt" == "(($outBgn - 1 ))" )) # there are data in this string #${#eVarIN[@]} then (( j = 0 )) for (( i = $outBgn ; i < cntOut ; i++ )) do # get value for output vars eDataOUT[$j]=${eDatLine[$i]} # echo "DEBUG ${eVarOUT[$j]}=${eDataOUT[$j]}" ((j++)) done ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done ) >> $eTmpFile # create temporary file for setap vars eIsFind=1 # echo OK: ${eVarIN[@]} == ${eDataIN[@]} '=>' ${eVarOUT[@]} == ${eDataOUT[@]} fi fi else #skeep empty and commets lines # echo Comment: $Line eDeb="" # for skeep warning fi done #while read Line ######################################################################3 IFS=$OLD_IFS #rm $eTmpFile
.
.
, – ? , , .
, , .
( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message
. , .
# ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setup vars
tmpSetVar.sh , Result="OK"
Result="OK"
ToDo=""
Speed=""
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong ramp police";
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong let have road";
ToDoAlter=""
SpeedAlter=""
. – .
, .
Perl - , .
.
CheckTabel.sh #/bin/ksh #/bin/bash # # script CheckTabel.sh - check tabel data # # See on : http://www.linuxcookbook.ru/books/absguide/ch09s05.html # #12.02.2013 _aap_ created by Patratskiy Aleksey #26.02.2013 _aap_ RELAEASE work with errors, get first right parametrs #28.02.2013 _aap_ fix same problem var counts #05.03.2013 _aap_ can use without <END> # #Limits : #Comment '#' work only for first position in string #Devior TAB If parameters use TAB it can not be used #input data: Conditions # # after you can check variable "CheckTabelErrors" for errors count #exaple of var :Conditions #Conditions=' ##check stuff of vars and data #Check var parametrs #varIn1 varIn2 varIn3 varIn4 => varOut1 varOut2 #varIn1varIn1 varIn2varIn2 varIn3varIn3 varIn4varIn4 => AAPvarOut1varOut1 AAPvarOut2varOut2 #<.> <_> <> dsf => sdf sdf #<ERROR> Error `exit 1` => <> <> #<END> #' #internals Vars: eTmpFile=$HOME/tmp/tmpSetVar.sh eDIVISOR=' ' eInOutDevisor='=>' eEND='<END>' eERROR='<ERROR>' eANY='<?>' eEMPTY='<_>' eNOTEMPTY='<.>' eISVAR=1 eDeb="" eIsFind=0 ((CheckTabelErrors=0)) ((eCurLine=0)) #for ksh typeset -A eDataIN typeset -A eDataOUT typeset -A eVarIN typeset -A eVarDatIN typeset -A eVarOUT typeset -A eVarLine typeset -A eDatLine #for bash #typeset -a eDataIN #typeset -a eDataOUT #typeset -a eVarIN #typeset -a eVarDatIN #typeset -a eVarOUT #typeset -a eVarLine #typeset -a eDatLine #source $eTmpFile # erase temporary file for setap vars > $eTmpFile # erase temporary file for setap vars #echo ifs=$IFS OLD_IFS="$IFS" IFS=$' '# echo "${Conditions}" | while read Line do ((eCurLine++)) # echo "LineErr: ${eCurLine}" ;echo "Line: ${Line}" if [[ "${Line:0:1}" != "#" && "$Line" != "" && "${Line:0:${#eEND}}" != "${eEND}" ]] #skeep empty and commets lines AND with <END> then if [[ "eISVAR" -eq "1" ]] # check for var names line then eISVAR=0 eVarLine=(`echo "$Line"`) cntIn=${#eVarLine[@]} # echo ${#eVarLine[@]} ${eVarLine[@]} for (( i = 0 ; i < cntIn ; i++ )) do #get names of input vars if [ "${eVarLine[${i}]}" == "${eInOutDevisor}" ] then ((outBgn=i + 1)) break fi eVarIN[${i}]=${eVarLine[$i]} tmp=${eVarLine[$i]} # get name of input var eval tmp=\$$tmp # gat var value by var name eVarDatIN[${i}]=${tmp} # echo DEBUG Element [$i]: ${eVarLine[$i]} val=${eVarIN[${i}]} eVarDatIN=${eVarDatIN[${i}]} done # echo DEBUG outBgn=$outBgn cntIn=$cntIn if (( cntIn == 0 || outBgn == 0 )) then echo !!! Error CheckTabel.sh formating outBgn=$outBgn cntIn=$cntIn wrong eDIVISOR TAB continue fi (( j = 0 )) for (( i = $outBgn ; i < cntIn ; i++ )) do # get name of output vars # echo "${eVarLine[$i]}=Set${i}" eVarOUT[$j]=${eVarLine[$i]} ((j++)) done eIsFind=0 # not finde yet # echo eVarIN ${#eVarIN[@]}: ${eVarIN[@]} ; echo eVarOUT ${#eVarOUT[@]}: ${eVarOUT[@]} ################################################################################### else if [[ "${Line:0:${#eEND}}" == "${eEND}" ]] # check for end of sentence then # echo "END: $Line" #echo "Line: ${Line:0:${#eEND}} == " # eISVAR=1 # source $eTmpFile #. data-file # execute file and set values for vars # > $eTmpFile # erase temporary file for setap vars continue # while read Line fi # #Check for error message and error vars set # if [[ "${Line:0:${#eERROR}}" == "${eERROR}" ]] # check for ERROR of sentence then # echo "<ERROR>:${eIsFind} $Line" #echo "Line: ${Line:0:${#eEND}} == " LineErr="" if [[ "eIsFind" -eq "0" ]] then ((CheckTabelErrors++)) LineErr="${Line#${eERROR}}" #remove <Error> echo "!!! ERROR CheckTabel.sh LineErr: ${eCurLine}" #;echo "Line: ${Line}" ErrVarOut="${LineErr#*${eInOutDevisor}}" #+ ${#eInOutDevisor}+ LineErr="${LineErr%${eInOutDevisor}*}" eDataOUT=( `echo "$ErrVarOut"` ) ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message fi # ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setap vars continue # while read Line fi #for skeep all next currient tabel parametrs if [[ "eIsFind" -eq "1" ]] then continue # while read Line fi eDatLine=( `echo "$Line"` ) # echo OUT ${#eDatLine[@]} ${eDatLine[@]} cntOut=${#eDatLine[@]} if (( $cntIn != $cntOut )) then echo !!! Error CheckTabel.sh in Conditions line=${eCurLine} formating Vars $cntIn but Data $cntOut, count of parametrs not equel ! ;echo !!! ${eVarIN[@]} === ${eDatLine[@]} continue # while read Line fi # # main check for compare tabale value and var value in currient string # ((cmpCnt=0)) for (( i = 0 ; i < cntOut ; i++ )) do #get input data if [ "${eDatLine[${i}]}" == "${eInOutDevisor}" ] ; then ((outBgn=i + 1)) break fi # echo DEBUG Element [$i]: ${eDatLine[$i]} val=${!eDatLine[$i]} eDatLine=${eDatLine[${i}]} == eVarDatIN="${eVarDatIN[$i]}" if [ "${eDatLine[${i}]}" == "${eVarDatIN[$i]}" ] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eANY}" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eNOTEMPTY}" && "${eVarDatIN[$i]}" != "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eEMPTY}" && "${eVarDatIN[$i]}" == "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi done # echo DEBUG "$cmpCnt" == "(($outBgn - 1 ))" outBgn=$outBgn cntIn=$cntIn if (( "$cmpCnt" == "(($outBgn - 1 ))" )) # there are data in this string #${#eVarIN[@]} then (( j = 0 )) for (( i = $outBgn ; i < cntOut ; i++ )) do # get value for output vars eDataOUT[$j]=${eDatLine[$i]} # echo "DEBUG ${eVarOUT[$j]}=${eDataOUT[$j]}" ((j++)) done ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done ) >> $eTmpFile # create temporary file for setap vars eIsFind=1 # echo OK: ${eVarIN[@]} == ${eDataIN[@]} '=>' ${eVarOUT[@]} == ${eDataOUT[@]} fi fi else #skeep empty and commets lines # echo Comment: $Line eDeb="" # for skeep warning fi done #while read Line ######################################################################3 IFS=$OLD_IFS #rm $eTmpFile
.
.
, – ? , , .
, , .
( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message
. , .
# ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setup vars
tmpSetVar.sh , Result="OK"
Result="OK"
ToDo=""
Speed=""
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong ramp police";
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong let have road";
ToDoAlter=""
SpeedAlter=""
. – .
, .
Perl - , .
.
CheckTabel.sh #/bin/ksh #/bin/bash # # script CheckTabel.sh - check tabel data # # See on : http://www.linuxcookbook.ru/books/absguide/ch09s05.html # #12.02.2013 _aap_ created by Patratskiy Aleksey #26.02.2013 _aap_ RELAEASE work with errors, get first right parametrs #28.02.2013 _aap_ fix same problem var counts #05.03.2013 _aap_ can use without <END> # #Limits : #Comment '#' work only for first position in string #Devior TAB If parameters use TAB it can not be used #input data: Conditions # # after you can check variable "CheckTabelErrors" for errors count #exaple of var :Conditions #Conditions=' ##check stuff of vars and data #Check var parametrs #varIn1 varIn2 varIn3 varIn4 => varOut1 varOut2 #varIn1varIn1 varIn2varIn2 varIn3varIn3 varIn4varIn4 => AAPvarOut1varOut1 AAPvarOut2varOut2 #<.> <_> <> dsf => sdf sdf #<ERROR> Error `exit 1` => <> <> #<END> #' #internals Vars: eTmpFile=$HOME/tmp/tmpSetVar.sh eDIVISOR=' ' eInOutDevisor='=>' eEND='<END>' eERROR='<ERROR>' eANY='<?>' eEMPTY='<_>' eNOTEMPTY='<.>' eISVAR=1 eDeb="" eIsFind=0 ((CheckTabelErrors=0)) ((eCurLine=0)) #for ksh typeset -A eDataIN typeset -A eDataOUT typeset -A eVarIN typeset -A eVarDatIN typeset -A eVarOUT typeset -A eVarLine typeset -A eDatLine #for bash #typeset -a eDataIN #typeset -a eDataOUT #typeset -a eVarIN #typeset -a eVarDatIN #typeset -a eVarOUT #typeset -a eVarLine #typeset -a eDatLine #source $eTmpFile # erase temporary file for setap vars > $eTmpFile # erase temporary file for setap vars #echo ifs=$IFS OLD_IFS="$IFS" IFS=$' '# echo "${Conditions}" | while read Line do ((eCurLine++)) # echo "LineErr: ${eCurLine}" ;echo "Line: ${Line}" if [[ "${Line:0:1}" != "#" && "$Line" != "" && "${Line:0:${#eEND}}" != "${eEND}" ]] #skeep empty and commets lines AND with <END> then if [[ "eISVAR" -eq "1" ]] # check for var names line then eISVAR=0 eVarLine=(`echo "$Line"`) cntIn=${#eVarLine[@]} # echo ${#eVarLine[@]} ${eVarLine[@]} for (( i = 0 ; i < cntIn ; i++ )) do #get names of input vars if [ "${eVarLine[${i}]}" == "${eInOutDevisor}" ] then ((outBgn=i + 1)) break fi eVarIN[${i}]=${eVarLine[$i]} tmp=${eVarLine[$i]} # get name of input var eval tmp=\$$tmp # gat var value by var name eVarDatIN[${i}]=${tmp} # echo DEBUG Element [$i]: ${eVarLine[$i]} val=${eVarIN[${i}]} eVarDatIN=${eVarDatIN[${i}]} done # echo DEBUG outBgn=$outBgn cntIn=$cntIn if (( cntIn == 0 || outBgn == 0 )) then echo !!! Error CheckTabel.sh formating outBgn=$outBgn cntIn=$cntIn wrong eDIVISOR TAB continue fi (( j = 0 )) for (( i = $outBgn ; i < cntIn ; i++ )) do # get name of output vars # echo "${eVarLine[$i]}=Set${i}" eVarOUT[$j]=${eVarLine[$i]} ((j++)) done eIsFind=0 # not finde yet # echo eVarIN ${#eVarIN[@]}: ${eVarIN[@]} ; echo eVarOUT ${#eVarOUT[@]}: ${eVarOUT[@]} ################################################################################### else if [[ "${Line:0:${#eEND}}" == "${eEND}" ]] # check for end of sentence then # echo "END: $Line" #echo "Line: ${Line:0:${#eEND}} == " # eISVAR=1 # source $eTmpFile #. data-file # execute file and set values for vars # > $eTmpFile # erase temporary file for setap vars continue # while read Line fi # #Check for error message and error vars set # if [[ "${Line:0:${#eERROR}}" == "${eERROR}" ]] # check for ERROR of sentence then # echo "<ERROR>:${eIsFind} $Line" #echo "Line: ${Line:0:${#eEND}} == " LineErr="" if [[ "eIsFind" -eq "0" ]] then ((CheckTabelErrors++)) LineErr="${Line#${eERROR}}" #remove <Error> echo "!!! ERROR CheckTabel.sh LineErr: ${eCurLine}" #;echo "Line: ${Line}" ErrVarOut="${LineErr#*${eInOutDevisor}}" #+ ${#eInOutDevisor}+ LineErr="${LineErr%${eInOutDevisor}*}" eDataOUT=( `echo "$ErrVarOut"` ) ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message fi # ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setap vars continue # while read Line fi #for skeep all next currient tabel parametrs if [[ "eIsFind" -eq "1" ]] then continue # while read Line fi eDatLine=( `echo "$Line"` ) # echo OUT ${#eDatLine[@]} ${eDatLine[@]} cntOut=${#eDatLine[@]} if (( $cntIn != $cntOut )) then echo !!! Error CheckTabel.sh in Conditions line=${eCurLine} formating Vars $cntIn but Data $cntOut, count of parametrs not equel ! ;echo !!! ${eVarIN[@]} === ${eDatLine[@]} continue # while read Line fi # # main check for compare tabale value and var value in currient string # ((cmpCnt=0)) for (( i = 0 ; i < cntOut ; i++ )) do #get input data if [ "${eDatLine[${i}]}" == "${eInOutDevisor}" ] ; then ((outBgn=i + 1)) break fi # echo DEBUG Element [$i]: ${eDatLine[$i]} val=${!eDatLine[$i]} eDatLine=${eDatLine[${i}]} == eVarDatIN="${eVarDatIN[$i]}" if [ "${eDatLine[${i}]}" == "${eVarDatIN[$i]}" ] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eANY}" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eNOTEMPTY}" && "${eVarDatIN[$i]}" != "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eEMPTY}" && "${eVarDatIN[$i]}" == "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi done # echo DEBUG "$cmpCnt" == "(($outBgn - 1 ))" outBgn=$outBgn cntIn=$cntIn if (( "$cmpCnt" == "(($outBgn - 1 ))" )) # there are data in this string #${#eVarIN[@]} then (( j = 0 )) for (( i = $outBgn ; i < cntOut ; i++ )) do # get value for output vars eDataOUT[$j]=${eDatLine[$i]} # echo "DEBUG ${eVarOUT[$j]}=${eDataOUT[$j]}" ((j++)) done ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done ) >> $eTmpFile # create temporary file for setap vars eIsFind=1 # echo OK: ${eVarIN[@]} == ${eDataIN[@]} '=>' ${eVarOUT[@]} == ${eDataOUT[@]} fi fi else #skeep empty and commets lines # echo Comment: $Line eDeb="" # for skeep warning fi done #while read Line ######################################################################3 IFS=$OLD_IFS #rm $eTmpFile
.
.
, – ? , , .
, , .
( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message
. , .
# ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setup vars
tmpSetVar.sh , Result="OK"
Result="OK"
ToDo=""
Speed=""
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong ramp police";
ToDo="$ToDo"
Speed="$Speed"
echo "Wrong let have road";
ToDoAlter=""
SpeedAlter=""
. – .
, .
Perl - , .
.
CheckTabel.sh #/bin/ksh #/bin/bash # # script CheckTabel.sh - check tabel data # # See on : http://www.linuxcookbook.ru/books/absguide/ch09s05.html # #12.02.2013 _aap_ created by Patratskiy Aleksey #26.02.2013 _aap_ RELAEASE work with errors, get first right parametrs #28.02.2013 _aap_ fix same problem var counts #05.03.2013 _aap_ can use without <END> # #Limits : #Comment '#' work only for first position in string #Devior TAB If parameters use TAB it can not be used #input data: Conditions # # after you can check variable "CheckTabelErrors" for errors count #exaple of var :Conditions #Conditions=' ##check stuff of vars and data #Check var parametrs #varIn1 varIn2 varIn3 varIn4 => varOut1 varOut2 #varIn1varIn1 varIn2varIn2 varIn3varIn3 varIn4varIn4 => AAPvarOut1varOut1 AAPvarOut2varOut2 #<.> <_> <> dsf => sdf sdf #<ERROR> Error `exit 1` => <> <> #<END> #' #internals Vars: eTmpFile=$HOME/tmp/tmpSetVar.sh eDIVISOR=' ' eInOutDevisor='=>' eEND='<END>' eERROR='<ERROR>' eANY='<?>' eEMPTY='<_>' eNOTEMPTY='<.>' eISVAR=1 eDeb="" eIsFind=0 ((CheckTabelErrors=0)) ((eCurLine=0)) #for ksh typeset -A eDataIN typeset -A eDataOUT typeset -A eVarIN typeset -A eVarDatIN typeset -A eVarOUT typeset -A eVarLine typeset -A eDatLine #for bash #typeset -a eDataIN #typeset -a eDataOUT #typeset -a eVarIN #typeset -a eVarDatIN #typeset -a eVarOUT #typeset -a eVarLine #typeset -a eDatLine #source $eTmpFile # erase temporary file for setap vars > $eTmpFile # erase temporary file for setap vars #echo ifs=$IFS OLD_IFS="$IFS" IFS=$' '# echo "${Conditions}" | while read Line do ((eCurLine++)) # echo "LineErr: ${eCurLine}" ;echo "Line: ${Line}" if [[ "${Line:0:1}" != "#" && "$Line" != "" && "${Line:0:${#eEND}}" != "${eEND}" ]] #skeep empty and commets lines AND with <END> then if [[ "eISVAR" -eq "1" ]] # check for var names line then eISVAR=0 eVarLine=(`echo "$Line"`) cntIn=${#eVarLine[@]} # echo ${#eVarLine[@]} ${eVarLine[@]} for (( i = 0 ; i < cntIn ; i++ )) do #get names of input vars if [ "${eVarLine[${i}]}" == "${eInOutDevisor}" ] then ((outBgn=i + 1)) break fi eVarIN[${i}]=${eVarLine[$i]} tmp=${eVarLine[$i]} # get name of input var eval tmp=\$$tmp # gat var value by var name eVarDatIN[${i}]=${tmp} # echo DEBUG Element [$i]: ${eVarLine[$i]} val=${eVarIN[${i}]} eVarDatIN=${eVarDatIN[${i}]} done # echo DEBUG outBgn=$outBgn cntIn=$cntIn if (( cntIn == 0 || outBgn == 0 )) then echo !!! Error CheckTabel.sh formating outBgn=$outBgn cntIn=$cntIn wrong eDIVISOR TAB continue fi (( j = 0 )) for (( i = $outBgn ; i < cntIn ; i++ )) do # get name of output vars # echo "${eVarLine[$i]}=Set${i}" eVarOUT[$j]=${eVarLine[$i]} ((j++)) done eIsFind=0 # not finde yet # echo eVarIN ${#eVarIN[@]}: ${eVarIN[@]} ; echo eVarOUT ${#eVarOUT[@]}: ${eVarOUT[@]} ################################################################################### else if [[ "${Line:0:${#eEND}}" == "${eEND}" ]] # check for end of sentence then # echo "END: $Line" #echo "Line: ${Line:0:${#eEND}} == " # eISVAR=1 # source $eTmpFile #. data-file # execute file and set values for vars # > $eTmpFile # erase temporary file for setap vars continue # while read Line fi # #Check for error message and error vars set # if [[ "${Line:0:${#eERROR}}" == "${eERROR}" ]] # check for ERROR of sentence then # echo "<ERROR>:${eIsFind} $Line" #echo "Line: ${Line:0:${#eEND}} == " LineErr="" if [[ "eIsFind" -eq "0" ]] then ((CheckTabelErrors++)) LineErr="${Line#${eERROR}}" #remove <Error> echo "!!! ERROR CheckTabel.sh LineErr: ${eCurLine}" #;echo "Line: ${Line}" ErrVarOut="${LineErr#*${eInOutDevisor}}" #+ ${#eInOutDevisor}+ LineErr="${LineErr%${eInOutDevisor}*}" eDataOUT=( `echo "$ErrVarOut"` ) ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done echo "${LineErr}" # error command ) >> $eTmpFile # create temporary file for setup vars and show error message fi # ---------- execute -------------- eISVAR=1 # its mean , that next line will with varnames source $eTmpFile #. data-file # execute file and set values for vars > $eTmpFile # erase temporary file for setap vars continue # while read Line fi #for skeep all next currient tabel parametrs if [[ "eIsFind" -eq "1" ]] then continue # while read Line fi eDatLine=( `echo "$Line"` ) # echo OUT ${#eDatLine[@]} ${eDatLine[@]} cntOut=${#eDatLine[@]} if (( $cntIn != $cntOut )) then echo !!! Error CheckTabel.sh in Conditions line=${eCurLine} formating Vars $cntIn but Data $cntOut, count of parametrs not equel ! ;echo !!! ${eVarIN[@]} === ${eDatLine[@]} continue # while read Line fi # # main check for compare tabale value and var value in currient string # ((cmpCnt=0)) for (( i = 0 ; i < cntOut ; i++ )) do #get input data if [ "${eDatLine[${i}]}" == "${eInOutDevisor}" ] ; then ((outBgn=i + 1)) break fi # echo DEBUG Element [$i]: ${eDatLine[$i]} val=${!eDatLine[$i]} eDatLine=${eDatLine[${i}]} == eVarDatIN="${eVarDatIN[$i]}" if [ "${eDatLine[${i}]}" == "${eVarDatIN[$i]}" ] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eANY}" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eNOTEMPTY}" && "${eVarDatIN[$i]}" != "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi if [[ "${eDatLine[${i}]}" == "${eEMPTY}" && "${eVarDatIN[$i]}" == "" ]] ; then # echo ${eDatLine[${i}]} == ${eVarDatIN[$i]} ((cmpCnt++)) eDataIN[$i]=${eDatLine[${i}]} fi done # echo DEBUG "$cmpCnt" == "(($outBgn - 1 ))" outBgn=$outBgn cntIn=$cntIn if (( "$cmpCnt" == "(($outBgn - 1 ))" )) # there are data in this string #${#eVarIN[@]} then (( j = 0 )) for (( i = $outBgn ; i < cntOut ; i++ )) do # get value for output vars eDataOUT[$j]=${eDatLine[$i]} # echo "DEBUG ${eVarOUT[$j]}=${eDataOUT[$j]}" ((j++)) done ( for (( i = 0 ; i < ${#eVarOUT[@]} ; i++ )) do echo "${eVarOUT[$i]}=\"${eDataOUT[$i]}\"" done ) >> $eTmpFile # create temporary file for setap vars eIsFind=1 # echo OK: ${eVarIN[@]} == ${eDataIN[@]} '=>' ${eVarOUT[@]} == ${eDataOUT[@]} fi fi else #skeep empty and commets lines # echo Comment: $Line eDeb="" # for skeep warning fi done #while read Line ######################################################################3 IFS=$OLD_IFS #rm $eTmpFile