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 > If Then Clause

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-29-07, 17:58
gauravjain21 gauravjain21 is offline
Registered User
 
Join Date: Mar 2005
Posts: 41
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
Reply With Quote
  #2 (permalink)  
Old 03-30-07, 02:35
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
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 02:38.
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