read command line as it is

I want to read the command line as it is in the script.
say
prompt$ a.sh 'inst_cont_Header__dss -v '" 0"' -m'

i want to use 'inst_cont_Header__dss -v '" 0"' -m' as it is, inside the scripts a.sh.

I've tried
$@
"$@"
$*
"$*"

but all of these in some way or other tamper the sting in the command line - these remove " or ' or sqeeze multiple spaces into one.

Please help.

on running - $ a.sh 'inst_cont_Header__dss -v '" 0"' -m'
required string - inst_cont_Header__dss -v '" 0"' -m
"$@" gives - inst_cont_Header__dss -v 0 -m

It removes ' or " from string .

Try:

a.sh inst_cont_Header__dss -v "'"\" 0\""'" -m

You can echo the variable in your script with:

echo "$@"

Regards

The problem is , this scripts have to generic ,, I' won't know what argument will be coming ..so won't able \ to escape..

Thanks for ur reply Frank!!

Is there any other way ...

What you have there is equivalent to:

inst_cont_Header__dss -v           0 -m

That is what the script sees.

If you want the shell to see something else, then it has to be written differently.

If the variable is unquoted multiple spaces are (except in rare instances) just separating arguments; the number of spaces is irrelevant.

Thanks for the reply.
But That is not the case
say i need to run the script OTP_Extract.sh that require some command line args eg -

$OTP_Extract.sh -v '" 0"' -m DAILY

-v is to passes " 0" to this. number of spaces around 0 are important.

But I need to run this by other script keeping all command OTP_Extract.sh and options -v '" 0"' -m DAILY in the command line args of other scritp ,say a.sh

I 'll use a.sh as -

$a.sh 'script and args'

and a.sh is like -

$cat a.sh
EXECUTE="$@"
ksh "${EXECUTE}"

The problem is that $@ doesn't pass 'script and args' properly if it have single quotes in between . I've tried escaping by back slash , but it doesn't work.
What I need is that If I echo $EXECUTE I shoud get -

OTP_Extract.sh -v '" 0"' -m DAILY

Please help.

say i need to run the script OTP_Extract.sh that require some command line args eg -

$OTP_Extract.sh -v '" 0"' -m DAILY

-v is to passes " 0" to this. number of spaces around 0 are important.

But I need to run this by other script keeping all command OTP_Extract.sh and options -v '" 0"' -m DAILY in the command line args of other scritp ,say a.sh

I 'll use a.sh as -

$a.sh 'script and args'

and a.sh is like -

$cat a.sh
EXECUTE="$@"
ksh "${EXECUTE}"

The problem is that $@ doesn't pass 'script and args' properly if it have single quotes in between . I've tried escaping by back slash , but it doesn't work.
What I need is that If I echo $EXECUTE I shoud get -

OTP_Extract.sh -v '" 0"' -m DAILY

Please help.

If quotes are acceptable:

a.sh:

#!/bin/sh

EXECUTE="$@"
echo "$EXECUTE"

command:

./a.sh OTP_Extract.sh -v "'"'"' 0'"'"'" -m DAILY

gives:

OTP_Extract.sh -v '" 0"' -m DAILY

Regards

In order to pass the spaces correctly, the command line must be properly quoted.

By assigning "$@" to a variable, you have removed any notion of separate arguments and stripped some of the quotes. Use:

ksh "$@"

But why do that? Why not run the command directly?

You cannot have single quotes inside a single-quoted string.

Then you must quote the string correctly on the command line.

I would suggest that you don't try to put everything into a single argument.

$ a.sh inst_cont_Header__dss -v '"          0"' -m

Or (more likely):

$ a.sh inst_cont_Header__dss -v "          0" -m