Hi
The following code works when reading the arguments from the command line but fails when I try to read from a string. So this works
while [ -n "$1" ]; do
case $1 in
-dbversion) if [ "`echo $2 | grep -e '^-[a-z]'`" ]; then { echo "ERROR: missing value for '$1' (seen '$2')"; usage; exit 1; } else { shift; INPUT_VERSION=$1; } fi ;;
-type) if [ "`echo $2 | grep -e '^-[a-z]'`" ]; then { echo "ERROR: missing value for '$1' (seen '$2')"; usage; exit 1; } else { shift; INPUT_TARGET_TYPE=$1; } fi ;;
-host) if [ "`echo $2 | grep -e '^-[a-z]'`" ]; then { echo "ERROR: missing value for '$1' (seen '$2')"; usage; exit 1; } else { shift; INPUT_HOST=$1; } fi ;;
*) echo "ERROR: unknown argument '$1'"; exit 1;;
esac
shift
done
but when I replace the line
while [ -n "$1" ]; do
witth
OPTPARMS="-dbversion 11.2.0.4.0 -type backup -host testhost"
while [ -n $OPTPARMS ]; do
it only sees the "ERROR: unknown argument"
Can somebody please tell me what the problem is?
Many thanks
Please ignore the old code (back ticks, echo etc.).