Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    37

    Unanswered: 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

  2. #2
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    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.

  3. #3
    Join Date
    Feb 2004
    Posts
    37

    Re: writing multiple conditions

    It works. Appreciate your help!

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •