[SunHELP] KSH Mystery

Sandwich Maker adh at an.bradford.ma.us
Tue Jul 29 09:58:32 CDT 2003


"From: Naser Ali <Ali.Naser at irs.gov>
"
"Gurus,
"
"This happened at leat three times before in the past and it is
"intermittent. Almost impossible to re-create. In this script we do a
"sequential grep for a specific string from a file and check for a condition,
"this is how it looks like
"
"============================================================================
"   232          echo
"   233          echo "Load started at `date`"
"   234          echo
"   235
"   236          i=0
"   237          DFLG="DIRECT=false"
"   238          while [ $i -lt ${#TBL_NAMES[*]} ]
"   239          do
"   240                  table=${TBL_NAMES[$i]}
"   241
"   242                  # Get the number of records for the above table
"   243                  NUM_REC=$(grep -i "$table\."
"$DATA_DIR/LOGS/$TAPENUMBER.$JULIANDAY.recs | cut -d' ' -f2)
"   244
"   245                  if [ $NUM_REC -gt 0 ]; then
"   246                          SKIP=0
"   247                          if [ ${TBL_LD_FLGS[$i]} -eq 1 ]; then
"   248                                  while [ $SKIP -lt $NUM_REC ]
"   249                                  do
"   250                                          sql_load $ORACLE_ID
"$LOADER_CTRL_DIR $table $DATA_DIR \
"   251                                                  $TAPENUMBER
"$JULIANDAY $DFLG $SKIP $21_SQLLOAD_SIZE &
"   252
"SKIP=$((SKIP+$21_SQLLOAD_SIZE))
"   253                                  done
"   254                          else
"   255                                  sql_load $ORACLE_ID $LOADER_CTRL_DIR
"$table $DATA_DIR \
"   256                                          $TAPENUMBER $JULIANDAY $DFLG
"$SKIP &
"   257                          fi
"   258                  fi
"   259
"   260                  i=$((i+1))
"   261          done
"   262
"============================================================================
"
"the error we recieve is 
"---------------------------------------------------
"/operator/bin/call_21[245]: test: argument expected
"ALL SQL*Loader processes completed successfully.
"---------------------------------------------------
"
"we do not understand why this happens even though all the string we are
"grepping for are there.
"Has anyone seen anything like it before. Is the ksh buggy. This is Solaris
"2.8 env.

obviously, what's happening is that $NUM_REC is null because the
grep/cut didn't return anything.  what proof do you have that it's
always filled?

i suggest that you try running the script with -x in the shell options.
you should also try double-quoting "$NUM_REC".  
________________________________________________________________________
Andrew Hay                                  the genius nature
internet rambler                            is to see what all have seen
adh at an.bradford.ma.us                       and think what none thought



More information about the SunHELP mailing list