Shell if elif else Code Example

export servername=`uname -n`
export serverlen=${#servername}
export serverenv=`echo $servername | cut -c$serverlen`
if [[ $serverenv=='d' ]]; then
     export SQL_GOLDEN=STEP_DEV_NY_DS
     export SQL_USER=hnwuser
     export SQL_PASSWD=Lip0v123
     export SQL_DB=hnwreport
     export SYB_DATA=/opt/HNW/HNWFileAnalysis/HNWOutput
     export SYB_LOG=/opt/HNW/HNWFileAnalysis/logs
     export BASENAME="dataFeed"
     export PID="$$"
     export SYBASE=/optware/sybase/aseclient1503x
     . /optware/sybase/aseclient1503x/SYBASE.sh
elif [[$serverenv=='u' ]]; then
     export SQL_GOLDEN=STEP_UAT_NY_DS
     export SQL_USER=hnwuser
     export SQL_PASSWD=Lip0v321
     export SQL_DB=hnwreport
     export SYB_DATA=/opt/HNW/HNWFileAnalysis/HNWOutput
     export SYB_LOG=/opt/HNW/HNWFileAnalysis/logs
     export BASENAME="dataFeed"
     export PID="$$"
     export SYBASE=/optware/aseclient1503x/ase155b
     . /optware/sybase/aseclient1503x/SYBASE.sh
elif [[$serverenv=='p' ]]; then
     export SQL_GOLDEN=STEP_PROD_NY_DS
     export SQL_USER=hnwuser
     export SQL_PASSWD=Lip0v123
     export SQL_DB=hnwreport
     export SYB_DATA=/opt/HNW/HNWFileAnalysis/HNWOutput
     export SYB_LOG=/opt/HNW/HNWFileAnalysis/logs
     export BASENAME="dataFeed"
     export PID="$$"
     export SYBASE=/optware/aseclient1503x/ase155b
     . //optware/aseclient1503x/ase155b/SYBASE.sh
fi

你可能感兴趣的:(Shell if elif else Code Example)