Shell Usage Sample

 Sample 1:

if [ $# -ne 1 ]

then

        echo "Usage: `basename $0` {INTG|UA}"

        exit -1

else

        INPUT=`echo $1 | tr '[:lower:]' '[:upper:]'`

        if [ "$INPUT" = "UA" ]; then

                DBCONNECT_STRING=$DBCONNECT_STRING_CORP_POS_UAT

        elif [ "$INPUT" = "INTG" ]; then

                DBCONNECT_STRING=$DBCONNECT_STRING_CORP_POS_INTG

        else

                echo "Unkown parameter: $1"

                exit -1

        fi

fi

 

Sample 2:

if [ $# -ne 2 ]

then

echo "Usage: `basename $0` {PORT-NUMBER} {MBEAN-NAME}"

exit -1

else 

RET=`expr match $1 "[0-9]*$"`

 

        if [ "$RET" -gt 0 ]; then

                       echo "Port number is: $1"

        else

echo "Invalid port number: $1"

exit -1

               fi

echo "MBean name is: $2"

fi

你可能感兴趣的:(Environment)