On Sat, Jan 16, 2010 at 10:32 PM, salih k <kmsa...@gmail.com> wrote: > > > On Sat, Jan 16, 2010 at 10:03 PM, Eric Blake <e...@byu.net> wrote: > > >> According to salih k on 1/16/2010 6:38 AM: >> >> > Hi, >> > >> > thank you for the patiance ..I am sorry for being top posted. >> > The piece of script is to check alphanumeric >> > >> > BH(batch header) for the file having issue is >> > BH|660|FILE1|2009/12/30|28|28|19.80||878.000| >> > IS|123|456| >> > FILE2 >> > BH|660|FILE2|2009/12/30|1|1|19.80||878.000| >> > >> > Piece of Script >> > ------------------------ >> > isnum=`awk -F$delim '$1=="BH"{print $5}' $fil` >> > # HERE 5 THE FIELD FILE1 IS sum of records =28 >> > #awk -F$delim '$1=="BH"{print $5}' $fil |read isnum >> > log_msg "Debug msg1 File $fil has isnum $isnum" >> > isnum=${isnum:-0} >> > log_msg "Debug msg2 File $fil has isnum $isnum" >> > int_num=`echo -e $isnum | cut -f1 -d'.'` >> > log_msg "Debug msg3 File $fil has int_num $int_num" >> > add_num=`expr $int_num + 1 1>/dev/null 2>&1` >> > if [ "$?" -ne "0" ] then >> > >> > padd_num=`expr $int_num + 1 1>/dev/null 2>&1` >> > log_msg "Debug msg4 File $fil with paddnum has expr pstat $?" >> > #padd_num1=`expr $int_num + 1` >> > log_msg "Debug msg5 File $fil with paddnum1 $padd_num1 pstat1 $?" >> > errmsg "File `basename $fil` has alpha-numeric value in >> > header record for total shipments !!! aborting" >> > sleep 1 >> > log_msg "Upload of $fil aborting" >> > log_msg >> "------------------------------------------------" >> > out_rep $repfil "\nFile `basename $fil` has >> > alpha-numeric value in header record for total shipments !!! aborting" >> > continue >> > fi >> >> > continue for next check >> >> > Note:This issue happens only very rate bu this also need to be >> eliminated. >> > I am able to simulate it once .Please find the below debug output >> > Debug msg1 File FILE1 has isnum 28 and pstat 0 >> > Debug msg2 File FILE1 has isnum 28 >> > Debug msg3 File FILE1 has int_num 28 has ps 0 >> > Debug msg3.1 File FILE1 has int_num1 28 has ps 0 >> > Debug msg4.new1 File has expr pstat 51198 int_num is 28 >> >> >> You aren't helping us help you. There is nothing that says new1 in the >> script you posted above. Until you post EXACTLY what you ran, and EXACTLY >> what it produced, there's no way we can tell you why your message that >> includes the text new1 is printing the value 51198. >> >> > 1. is it becuase of expr command is not stable in linux and need to >> > upgrade or use other commands like case as you given?The same script is >> > working without any issue in unix >> >> >> expr is more or less stable, but it is ALWAYS a good idea to report bugs >> against the latest version (if indeed it is a bug in expr). But more >> likely, the bug is in your script, and not expr. >> >> -- >> > > Don't work too hard, make some time for fun as well! > > Eric Blake e...@byu.net > > > Hi, > the piece of script is to check alphanumeric > > BH(batch header) for the file having issue is > BH|660|FILE1|2009/12/30|28|28|19.80||878.000| > IS|123|456| > FILE2 > BH|660|FILE2|2009/12/30|1|1|19.80||878.000| > > Piece of Script > -------------------------- > > *isnum=`awk -F$delim '$1=="BH"{print $5}' $fil`* > * > #awk -F$delim '$1=="BH"{print $5}' $fil |read isnum > log_msg "Debug msg1 File $fil has isnum $isnum and pstat $?" > isnum=${isnum:-0} > log_msg "Debug msg2 File $fil has isnum $isnum" > int_num=`echo -e $isnum | cut -f1 -d'.'` > log_msg "Debug msg3 File $fil has int_num $int_num has ps $?" > int_num1=`echo $isnum | cut -f1 -d'.'` > log_msg "Debug msg3.1 File $fil has int_num1 $int_num1 has ps $?" > add_num=`expr $int_num + 1 1>/dev/null 2>&1` > kms=$? > # if [ "$?" -ne "0" ] > if [ "$kms" -ne "0" ] > then > log_msg "Debug msg4.new1 File has expr pstat $kms int_num is > $int_num" > padd_num=`expr $int_num + 1 1>/dev/null 2>&1` > log_msg "Debug msg4 File $fil with paddnum has expr pstat $?" > padd_num1=`expr $int_num + 1 2>/dev/null` > log_msg "Debug msg5 File $fil with paddnum1 $padd_num1 pstat1 $?" > padd_num2=`expr $int_num + 1 1>/dev/null 2>&1` > if [ $? -ne 0 ] > then > log_msg "Debug msg6 for padd_num2 has psat $?" > fi > * > * errmsg "File `basename $fil` has alpha-numeric value in > header record for total shipments !!! aborting"* > sleep 1 > log_msg "Upload of $fil aborting" > log_msg "------------------------------------------------" > out_rep $repfil "\nFile `basename $fil` has alpha-numeric > value in header record for total shipments !!! aborting" > continue > fi > * chklines $delim $fil "IS" 1 1 > if [ $lin -ne $isnum ] > then > log_msg "Debug msg10 IS with lin $lin has pstat $?" > no_of_line=$lin > errmsg "File `basename $fil` has $no_of_line number of > detail lines instead of $isnum !!! aborting" > sleep 1 > log_msg "Upload of $fil aborting" > log_msg "------------------------------------------------" > out_rep $repfil "\nFile `basename $fil` has $no_of_line no > of detail lines instead of $isnum !!! aborting" > continue > fi > # Check number of fields in extract_control, extract_shipment and > extract_extra_chg records > chklines $delim $fil "BH" 1 2 > if [ $lin -ne 9 ] > then > * > *. *. . .. > > . . . . > Note:This issue happens only very rate bu this also need to be > eliminated. > I am able to simulate it once .Please find the below debug output > Debug msg1 File FILE1 has isnum 28 and pstat 0 > Debug msg2 File FILE1 has isnum 28 > Debug msg3 File FILE1 has int_num 28 has ps 0 > Debug msg3.1 File FILE1 has int_num1 28 has ps 0 > Debug msg4.new1 File has expr pstat 51198 int_num is 28 > Debug msg4 File FILE1 with paddnum has expr pstat 0 > Debug msg5 File FILE1 with paddnum1 29 pstat1 0 > File FILE1 has alpha-numeric value in header record for total shipments !!! > aborting > Upload of FILE1 aborting > ============================= > > Debug msg3 File FILE2 has int_num 1 has ps 0 > Debug msg3.1 File FILE2 has int_num1 1 has ps 0 > Debug msg4.new1 File has expr pstat 1552 int_num is 1 > Debug msg4 File FILE2 with paddnum has expr pstat 0 > These records then loaded succesfully after running it again!!! without > any code change > 51198 mod 256= 254 > 1552 mod 256=16 > is it becuase of expr command is not stable in linux and need to upgrade > or use other commands like case as you given?The same script is working > without any issue in unix > > Please advise whether I have to change the logic.Also it is initailly run > with cronjob then some recror failed so we will do rerun.This was never > happened in unix. > Is it because add_num=`expr $int_num + *1 1>/dev*/null 2>&1` whether i > have to chanage it to > add_num=`expr $int_num + *1 >*/dev/null 2>&1`? > > Thanks, > Salih > >
========================================= Hi, input file structure ----------------------- BH(batch header) for the file having issue is BH|660|FILE1|2009/12/30|28|28|19.80||878.000| IS|123|456| FILE2 BH|660|FILE2|2009/12/30|1|1|19.80||878.000| Piece of Script -------------------------- isnum=`awk -F$delim '$1=="BH"{print $5}' $fil` #awk -F$delim '$1=="BH"{print $5}' $fil |read isnum log_msg "Debug msg1 File $fil has isnum $isnum and pstat $?" isnum=${isnum:-0} log_msg "Debug msg2 File $fil has isnum $isnum" int_num=`echo -e $isnum | cut -f1 -d'.'` log_msg "Debug msg3 File $fil has int_num $int_num has ps $?" int_num1=`echo $isnum | cut -f1 -d'.'` log_msg "Debug msg3.1 File $fil has int_num1 $int_num1 has ps $?" add_num=`expr $int_num + 1 1>/dev/null 2>&1` kms=$? # if [ "$?" -ne "0" ] if [ "$kms" -ne "0" ] then log_msg "Debug msg4.new1 File has expr pstat $kms int_num is $int_num" padd_num=`expr $int_num + 1 1>/dev/null 2>&1` log_msg "Debug msg4 File $fil with paddnum has expr pstat $?" padd_num1=`expr $int_num + 1 2>/dev/null` log_msg "Debug msg5 File $fil with paddnum1 $padd_num1 pstat1 $?" padd_num2=`expr $int_num + 1 1>/dev/null 2>&1` if [ $? -ne 0 ] then log_msg "Debug msg6 for padd_num2 has psat $?" fi errmsg "File `basename $fil` has alpha-numeric value in header record for total shipments !!! aborting" sleep 1 log_msg "Upload of $fil aborting" log_msg "------------------------------------------------" out_rep $repfil "\nFile `basename $fil` has alpha-numeric value in header record for total shipments !!! aborting" continue fi chklines $delim $fil "IS" 1 1 if [ $lin -ne $isnum ] then log_msg "Debug msg10 IS with lin $lin has pstat $?" no_of_line=$lin errmsg "File `basename $fil` has $no_of_line number of detail lines instead of $isnum !!! aborting" sleep 1 log_msg "Upload of $fil aborting" log_msg "------------------------------------------------" out_rep $repfil "\nFile `basename $fil` has $no_of_line no of detail lines instead of $isnum !!! aborting" continue fi # Check number of fields in extract_control, extract_shipment and extract_extra_chg records chklines $delim $fil "BH" 1 2 if [ $lin -ne 9 ] then . . . .. . . . . (Note:This issue happens only very rate bu this also need to be eliminated. ) errorlog ------------- I am able to simulate it once .Please find the below debug output Debug msg1 File FILE1 has isnum 28 and pstat 0 Debug msg2 File FILE1 has isnum 28 Debug msg3 File FILE1 has int_num 28 has ps 0 Debug msg3.1 File FILE1 has int_num1 28 has ps 0 Debug msg4.new1 File has expr pst*at 51198 int_num is 28* Debug msg4 File FILE1 with paddnum has expr pstat 0 Debug msg5 File FILE1 with paddnum1 29 pstat1 0 File FILE1 has alpha-numeric value in header record for total shipments !!! aborting Upload of FILE1 aborting ============================= Debug msg3 File FILE2 has int_num 1 has ps 0 Debug msg3.1 File FILE2 has int_num1 1 has ps 0 Debug msg4.new1 File has expr pstat *1552 int_num is 1 *Debug msg4 File FILE2 with paddnum has expr pstat 0 These records then loaded succesfully after running it again!!! without any code change 51198 mod 256= 254 1552 mod 256=16 is it becuase of expr command is not stable in linux and need to upgrade or use other commands like case as you given?The same script is working without any issue in unix Please advise whether I have to change the logic.Also it is initailly run with cronjob then some recror failed so we will do rerun.This was never happened in unix. Is it because add_num=`expr $int_num + 1 1>/dev/null 2>&1` whether i have to chanage it to add_num=`expr $int_num + 1 >/dev/null 2>&1`? *--Salih*