The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




Thread: getopts
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 03-26-2005
google's Avatar
google google is offline Forum Advisor  
Moderator
  
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
I didnt test this at all, just a thought I had. Im sure there are a million ways to do this.


Code:
USAGE="Usage: `basename $0` [-s schemaname] [-d databasename] [-u username] -f -t -h"
while getopts :s:d:u:fth params
do
   case $params in
     s) SOURCESCHEMA="$OPTARG"
        let COUNT= $COUNT+10000
         ;;
     f) FULL='y'
         ;;

     t) TABLE='y'
         ;;

     d) DBNAME="$OPTARG"
         let COUNT= $COUNT+1
        ;;

     u) USERNAME="$OPTARG"
         let COUNT= $COUNT+1000
         ;;
     h) 
         help_doc
         exit 0 
         ;;
     ?) 
         echo "Invalid Option Specified"
         echo "$USAGE" 1>&2 ; exit 1 
         ;;
   esac

if [ "$COUNT" -ne 10101 ]
  then
    help_doc
    exit 0
elif [ ! -z $FULL ]
   then
      echo "Paramater FULL is Set"
elif [ ! -z $TABLE ]
   then
      echo "Paramater TABLE is Set"
else
    echo "Neither TABLE or FULL Are Set"
fi