Operating System - HP-UX
1833012 Members
2862 Online
110048 Solutions
New Discussion

ksh error "parameter not set"

 
SOLVED
Go to solution
eric stewart
Frequent Advisor

ksh error "parameter not set"

I have this script extract.
I want to run it in the current shell.
How do I get past the error message as shown below. I have included the script and the output.
TIA
>cat tmap
if [ "${PROTOCOL_name}" = "" ]
then
echo enter protocol name
read PROTOCOL_name
fi

>. tmap

ksh: PROTOCOL_name: parameter not set
>
Good help is easy to find within forums
5 REPLIES 5
James R. Ferguson
Acclaimed Contributor

Re: ksh error "parameter not set"

Eric:

Try:

if [ -z "${PROTOCOL_name}" ]

...JRF...
Anthony deRito
Respected Contributor

Re: ksh error "parameter not set"

Eric, I agree, simply test the string size using the -z string test.

-z Operator The -z operator tests to determine if the string?s length is zero.
-n Operator The -n operator tests to determine of the string?s length is non-zero.

I would also unset the variable upfront.

Tony
Tom Danzig
Honored Contributor
Solution

Re: ksh error "parameter not set"

Try:

if [ "${PROTOCOL_name:-}" = "" ]
eric stewart
Frequent Advisor

Re: ksh error "parameter not set"

James,
This does not work under the original scenerio.
Thanks
The set +u does the trick.
Good help is easy to find within forums
eric stewart
Frequent Advisor

Re: ksh error "parameter not set"

Tom,
You solution also works. Thanks.
Now I have to choose:).
I guess I will make one of you unhappy.
Well, I will not tell you which one I chose.
You can fell as good or bad as you want!!
Thanks again.
Good help is easy to find within forums