How to pass parameters to your program in Shell script.

Links: http://www.dbatools.net/experience/unix_shell_pass_params.html

    I wrote some OCI program and compiled them into 32 bit executable on 64 bit Solaris machine. So I need to set the proper Oracle library path to get it work. I wrote a shell script to set some environment variables first, and then call my utility.

#!/bin/sh

if [ "A${ORACLE_HOME}A" = "AA" ]; then
   echo "ORACLE_HOME environment variable not setted."
   exit
fi

if [ "A${LD_LIBRARY_PATH}A" = "AA" ];then
   LD_LIBRARY_PATH=/lib:/usr/lib
fi

if [ -d ${ORACLE_HOME}/lib32 ]; then
   LD_LIBRARY_PATH=${ORACLE_HOME}/lib32:${LD_LIBRARY_PATH}
else
   LD_LIBRARY_PATH=${ORACLE_HOME}/lib:${LD_LIBRARY_PATH}
fi

ociuldr.bin "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"

    Later I added more and more command line options to my utility. Someday I found that my script did not work fine, some option values were not passed correctly to my utility. The reason was that only the first 9 options were passed to my utility. So I change the last line as following.

ociuldr.bin "$@"

    Now the problem get resolved.

Post a comment

« Previous | Main | Next »

Powered by
Movable Type 3.36