If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > writing multiple conditions

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-27-04, 11:17
gomes009 gomes009 is offline
Registered User
 
Join Date: Feb 2004
Posts: 37
writing multiple conditions

The following is the current code:

PROCESS_NAME= EXTRACT (returned by the database)
EXTRACT_NAME=EXTRACT
DATA_FILE_NAME=test.dat
SUMMARY_FILE_NAME=test.sum


if [ "$PROCESS_NAME" = "$EXTRACT_NAME" ];
then echo "String vals for $PROCESS_NAME and $EXTRACT_NAME are ="
CountA=`wc -l $DATA_FILE_NAME | awk '{print $1}'`
echo $CountA
CountB=`awk 'NR==1 {print $2;next}' $SUMMARY_FILE_NAME`
echo $CountB
if [ $CountA -eq $CountB ];
then
echo "Ok"

Process will write an SUCCESS record to the database
Else
Echo “Count Don’t Match”
Process will write an ERROR record to the database


The above works fine

The question is:

I need to check the following two conditions:

IF "$PROCESS_NAME" = "$EXTRACT_NAME" and
the $DATA_FILE_NAME and $SUMMARY_FILE_NAME files (always two files) have not arrived
the process should write “ERROR” to the database



IF "$PROCESS_NAME" = "$EXTRACT_NAME" and
the $DATA_FILE_NAME and $SUMMARY_FILE_NAME files have arrived

AND the counts match, the process will write a “SUCCESS” record in the database. (above code should work)

AND the counts don’t match, the process will write an “ERROR” record in the database. (above code should work)

Any help is appreciated
Reply With Quote
  #2 (permalink)  
Old 02-27-04, 12:34
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
You can do somthing like this :

Code:
PROCESS_NAME= EXTRACT (returned by the database)
EXTRACT_NAME=EXTRACT
DATA_FILE_NAME=test.dat
SUMMARY_FILE_NAME=test.sum

if [ "$PROCESS_NAME" = "$EXTRACT_NAME" ]
then
   if is_file_arrived "$DATA_FILE_NAME" && \
      is_file_arrived "$SUMMARY_FILE_NAME"
   then
      CountA=`wc -l $DATA_FILE_NAME | awk '{print $1}'`
      CountB=`awk 'NR==1 {print $2;next}' $SUMMARY_FILE_NAME`
      if [ "$CountA" -eq "$CountB" ]
      then
         echo "Ok"
         Process will write an SUCCESS record to the database
      else
         echo "Count Don’t Match"
         Process will write an ERROR record to the database
      fi
   else
      echo "Files not arrived"
      Process will write an ERROR record to the database     
   fi
else
   echo "PROCESS_NAME and EXTRACT_NAME values are different"
fi
__________________
Jean-Pierre.
Reply With Quote
  #3 (permalink)  
Old 02-27-04, 13:33
gomes009 gomes009 is offline
Registered User
 
Join Date: Feb 2004
Posts: 37
Re: writing multiple conditions

It works. Appreciate your help!

Thanks
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On