Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problems with variables in kornshell 1

Status
Not open for further replies.

renesteg

IS-IT--Management
Feb 28, 2001
3
CH
I try to execute the following command in a kornshell:
pcms ac $ChangeRequestID /STATUS=$nextStatus

where "pcms" is a programm of an API I use, "ac" the method of this API-function.
Now, when korn shell is gathering the variable "$nextStatus" it seems to stop with the gathering process, when the first Blank appears in the variable (content of $nextStatus is "INTEGRATION TEST").

Does anybody know, how I get the entire content out of the variable? Currently, the API-function returns the error, that I specified too many parameters (it is expecting 2 parameters and since only the first part of the string is gathered, the function "thinks" TEST is a further parameter).

Thanks for any help
René
 
Hi,

Could you try:
[tt]
pcms ac $ChangeRequestID "/STATUS=$nextStatus"
[/tt]

The double quotes are there to get the shell to treat the whole status thing as one parameter. Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
The problem was not in the command level, it was how I set the value for the variable I used.

When setting the variable like:
nextStatus="INTEGRATION TEST"

and using the command
pcms ac $ChangeRequestID /STATUS="$nextStatus"

the error occurs as described.

But when setting the variable like this:
nextStatus='"INTEGRATION TEST"' (using single quotes around the double quotes)

it works just fine.

I hope this may help others too.

Happy shelling! :)
Rene
 
Yay! thx Rene -- it was irrittating me that I couldn't figure it out. Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
I've got another problem with strings. I was reading a file using the read command like this:
while read offNormalStatus
do
....
done
Then I executed the command like this:

pcms ac $ChangeRequestID /STATUS="$offNormalStatus"

where $ChangeRequestID was always a single String and $offNormalStatus could have values like "PROD", "UNDER WORK"... And when the String "UNDER WORK" was the value of $offNormalStatus, then the error "Too many parameters" occured.

The solution is the following code:
cat << EOD >> $cmdlist
ac $ChangeRequestID /STATUS=&quot;$offNormalStatus&quot;
EOD
pcms < $cmdlist

Then the entire thing works fine, no matter if the string is a two- three- or one-word string, or whatever length it is.

Now I'm really happy and I hope this may help others too!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top