Passing blank arguments to a script

All,
I have a cron job script that receives several command line arguments. At some point if there are validation problems and the job cannot be run, it duplicates the entire command line into a temporary text file which is later executed as a script. Unfortunately when I pass the list of received arguments (ie: $*) to this new file, the quoted blank arguments are dismissed.

For example, my script "runbatch.sh" looks like this:
#!/bin/ksh
#runbatch.sh
if [ some validation fails ]
then
echo "$0 $*" >> retryjobs.sh
exit 1
fi

If runbatch.sh was run as:
runbatch.sh one two '' four five

It will convert the 2 single quotes to a blank when exporting the line to retryjobs.sh, thus removing the blank argument.

Here's what retryjobs.sh looks like:
runbatch.sh one two four five

I need those single quotes to be passed. Any ideas anyone??

Thanks

There is actually an entry in the man page to explain exactly this situation; use "$@"

How do you man "$@" ? It gives me errors:

->man "$@"
sh: @: Parameter not set.

Thanks,

R�al

no, I mean man ksh.

"$@" is what you should use in your script instean of $*

Oh sorry, I forgot the other bit, and use printf, not echo.

printf "'%s' " "$@" >> file
printf "\n" >> file

Thanks for the tip - I never tried man on ksh - kool :slight_smile:

Unfortunately either "$@" or "$*" produce an unquoted double space :confused:

How about trying to replace this double space with [space]

[quote]

[quote]
[space]. The 'tr' command doesn't seem quite fit to handle this. Remains 'sed' but I am not very familliar with it. Please help with the correct syntax:

echo "$@"|sed ??? >> retryjobs.sh

Thanks.

R�al

See my previous. I probably posted it while you were typing.

Yes. And it worked!! You the man :b:

Thanks for your help. It is very much appreciated.

R�al