|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to pass a parameter with double quotes around it to a command
In a bash script, I need to pass a parameter that has space in-between using double quotes as follows: Code:
CMD="SomeExecutable" # Parameter that has a space in-between Code:
PARAM1="TIMO 2" CMD_IN="--name=\"$PARAM1\"" CMD_OUT=`$CMD $CMD_IN` expected/required command execution: Code:
SomeExecutable --name="TIMO 2" But, what i see is: Code:
SomeExecutable '--name="TIMO' '2"' Why? How do I fix it ? Thank you! Last edited by Scott; 09-09-2010 at 11:57 AM.. Reason: Please use code tags |
| Sponsored Links | |
|
|
|
#3
|
|||
|
|||
|
Thanks for the response. Are you suggesting Code:
CMD="SomeExecutable" CMD_IN='--name="TIMO 2"' CMD_OUT=`$CMD $CMD_IN` Still, I get the following Code:
SomeExecutable '--name="TIMO' '2"' Not what is required (SomeExecutable --name="TIMO2") Last edited by Scott; 09-09-2010 at 11:56 AM.. Reason: Please use code tags |
|
#4
|
||||
|
||||
|
Hi. I get the right answer: Code:
$ cat SomeExecutable echo SOME EXECUTABLE HERE echo ARGS ARE echo $@ $ cat T1 CMD="./SomeExecutable" CMD_IN='--name="TIMO 2"' CMD_OUT=`$CMD $CMD_IN` echo $CMD_OUT $ ./T1 SOME EXECUTABLE HERE ARGS ARE --name="TIMO 2" Last edited by Scott; 09-09-2010 at 12:07 PM.. |
| The Following User Says Thank You to Scott For This Useful Post: | ||
Timo (09-09-2010) | ||
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Thank you. It works now with minor adjustment as follows: If the SomeExecutable is like this Code:
$ cat SomeExecutable echo SOME EXECUTABLE HERE echo ARGS ARE echo "P1="$1 echo "P2="$2 Then the output is, Code:
SOME EXECUTABLE HERE ARGS ARE P1=--name="TIMO P2=2" Fixing that required the following: Code:
$ cat T1 CMD="./SomeExecutable" CMD_IN='--name="TIMO 2"' CMD_OUT=`$CMD "$CMD_IN"` echo $CMD_OUT Then the output is, Code:
$ ./T1 SOME EXECUTABLE HERE ARGS ARE P1=--name="TIMO 2" P2= Last edited by Scott; 09-09-2010 at 01:12 PM.. Reason: Please use code tags |
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| unix command to insert double quotes in a delimited file | Bachu | UNIX for Dummies Questions & Answers | 6 | 06-17-2010 05:48 AM |
| How to alias an awk command with single and double quotes? | jacekmaciek | Shell Programming and Scripting | 2 | 06-03-2009 10:48 AM |
| ksh execute command containing double quotes | pearson05 | Shell Programming and Scripting | 1 | 05-02-2008 05:25 AM |
| unix command to insert double quotes | berlin_germany | Shell Programming and Scripting | 2 | 01-17-2007 12:07 PM |
| how to pass variables surrounded in double quotes to awk? | cruiser | AIX | 4 | 03-24-2006 04:12 PM |
|
|