passing parameters with spaces

we are using following script to execute stored procedue. The problem is run_pmcmd.ksh script is using $*
parameter which is not taking in account 'Men Shirt' parameter which includes spaces.

  1. Step 1
run_pmcmd.ksh  CONVERT_TEST 

script for run_pmcmd.ksh

/u01/$(whoami)/run_pmcmd.ksh Keae $*
  1. Step 2
    script for CONVERT_TEST
#parameters are userid, password, database, db link, owner, div, dept, style
U run_convert.ksh abc desf dev sdv XYZ 'Men Shirt' 44 7542
  1. Step 3
    script for run_convert.ksh
USER=$1;       export USER
PASSWD=$2;     export PASSWD
SID=$3;        export SID
DB=$4;         export DB
OWNER=$5;      export OWNER
DIV=$6;        export DIV
DEPT=$7;       export DEPT
STYLE=$8;      export STYLE
 
$ORACLE_HOME/bin/sqlplus ${USER}/${PASSWD}@${SID} >>./CONVERT_TEST${DEPT}.log <<EOC
whenever sqlerror exit 1
execute CNVT_SUMMARY('${DB}', '${OWNER}','${DIV}','${DEPT}','${STYLE}');
EOC

Thanks
Sandy

Use "$@" instead of $* (including the double quotes):

/u01/$(whoami)/run_pmcmd.ksh Keae "$@"

Sorry but I still got the same error and parameter did not pass through correctly.

Can you please post the whole run_convert.ksh and run_pmcmd.ksh and sample input.

Please find the run_convert.ksh in my first post. Actually problem is when passing parameter to stored procedure when the double quotes or single quotes are getting lost. Question - Please let me know how to pass parameter in "CONVERT_TEST
" script so that "run_convert.ksh" script can have 'Men Shirt' parameter. As of now it passing as 'Mens.

Where are these arguments coming from? How are the arguments supplied into $* / "$@" ? They may be already split by the time you get them, meaning, your script has to guess whether to un-split them or not...

Put this on a line by itself: printf "%s\n" "$@" and tell me what it prints. If 'men shirt' is split across two lines, then your script is already getting the arguments pre-split and the problem is in whatever is calling your script.

you are right, yes parameter is coming in two lines. Please let me know where and how to fix it.

"Men
Shirt"

I think it is has to do with Informatica - which does not take into consideration - double quote, single quote and script is using pmcmd commnd to run the script.

Repair the calling program so that it provides the parameters correctly.

Thanks I have added double quotes in parameters in Step 2 and step 3 but still the result is not as expected.
2. Step 2
script for CONVERT_TEST

#parameters are userid, password, database, db link, owner, div, dept, style
U run_convert.ksh "abc" "desf" "dev" "sdv" "XYZ" "Men Shirt" "44" "7542"
  1. Step 3
    script for run_convert.ksh
USER="$1";       export USER
PASSWD="$2";     export PASSWD
SID="$3";        export SID
DB="$4";         export DB
OWNER="$5";      export OWNER
DIV="$6";        export DIV
DEPT="$7";       export DEPT
STYLE="$8";      export STYLE
 
$ORACLE_HOME/bin/sqlplus ${USER}/${PASSWD}@${SID} >>./CONVERT_TEST${DEPT}.log <<EOC
whenever sqlerror exit 1
execute CNVT_SUMMARY('${DB}', '${OWNER}','${DIV}','${DEPT}','${STYLE}');
EOC
  1. Wrong Result because "Men Shirt" is in two different lines
"abc"
"desf"
"dev"
"sdv"
"XYZ"
"Men
Shirt"
"44"
"7542"

If your arguments can't be trusted, you'll have to reprocess them from scratch. Since they appear to contain quote characters, that's at least somewhat possible. xargs understands quotes, making it useful here.

It will also strip them out, allowing you to put them back only where you want them.

echo "Arguments before:"
printf "%s\n" "$@"

echo "$@" | tr '\n' ' ' | xargs -n 1 > /tmp/$$ # Print one argument per line into /tmp/$$
# Clear arguments
set --

# Read arguments back into $1 $2 ... in turn
while read LINE
do
        set -- "$@" "$LINE"
done < /tmp/$$
rm -f /tmp/$$

# See if they've been improved
echo "Arguments after:"
printf "%s\n" "$@"

It would be far better to fix the thing that's calling it, but I'm guessing your refusal to consider it means that's not an option.

Thanks for reply. I am open for changing calling script but have no idea what to change and which script to change.
Parameters which are being passed dont have quotes around

U run_convert.ksh abc desf dev sdv XYZ Men Shirt 44 7542

this is how parameter should be passed to stored procedure from script.

$1 - abc
$2 - desf
$3 - dev
$4- sdev
$5 - XYZ
$6 - Men Shirt 
$7 - 44
$8 - 7542
 

They obviously do, if my printf statement printed this:

"Men
Shirt"

My statement wouldn't have added those quotes, they must have been in the string.

So, try my code.

If it doesn't have quotes, your script can't guess which arguments belong where. Maybe the extra strings belong with "Mens" -- but maybe they belong with "XYZ" instead! Only the thing which called your script would know.