Null handling in scripts

Hi,
I face some problem with handling of nulls. I declare a variable - say i - and intialise to 0. Later I read it from console, wherein if I dont give any variable and press return key, I get this error:
"0403-004 Specify a parameter with this command"

Is there anyway to handle this error?

Thanks in advance..

MohanPrabu

Assuming that you are writing a shell script

Code:

if [ $1 = " " ]
then
echo "No Arguments"
else
<commands you want to execute>
fi

Or for true "nulls" and unset variables, etc..

[ -z "$i" ] && echo "nothing here"

Cheers
ZB

You can also default your variables using the builtins in Korn.


${parameter:-word} 
- If parameter is null or unset, word is substituted for parameter.
The value of parameter does not change.

${parameter:=word} 
- If parameter is null or unset, parameter is set to the value of word.

${parameter:?message}
- If parameter is null or unset, message is printed to standard error.
This checks that variables are set correctly.

${parameter:+word}
 - If parameter is set, word is substituted for parameter.
 The value of parameter does not change.