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.
Step 1
run_pmcmd.ksh CONVERT_TEST
script for run_pmcmd.ksh
/u01/$(whoami)/run_pmcmd.ksh Keae $*
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
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.
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.
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.