Results 1 to 2 of 2

Thread: If Then Clause

  1. #1
    Join Date
    Mar 2005
    Posts
    41

    Unanswered: If Then Clause

    How to parse data from the filename w/o its extension.

    Problem: If PEOB is included in the part of a filename that is supplied as input parameter, do one thing
    ELSE
    do another thing.

    Shel Script Example
    ==================

    #!/bin/ksh
    #$1 is a input parameter filename w/o the extension

    SHLIB_PATH=$SHLIB_PATH:/opt/g1/doc1

    cd /opt/g1/doc1/doc1bodi

    if [ filename has 'PEOB' ]; then
    echo "EOB"
    /opt/g1/doc1/doc1gen "EOB.hip" ops=test-hp.ops input-data="$1"
    else
    echo "REGULAR"
    /opt/g1/doc1/doc1gen "OK.hip" ops=test-hp.ops input-data="$1"
    fi

    es=$?
    if [ $es != 0 ]; then
    return $es
    fi

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Code:
    filename=$1
    case "$filename" in
      *PEOB*) echo "EOB"
         /opt/g1/doc1/doc1gen "EOB.hip" ops=test-hp.ops input-data="$1"
         es=$?
         ;;
      *) echo "REGULAR"
         /opt/g1/doc1/doc1gen "OK.hip" ops=test-hp.ops input-data="$1"
         es=$?
         ;;
    esac
    test $es -ne 0 && return $es
    Last edited by pdreyer; 03-30-07 at 03:38.

Posting Permissions

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