Dynamic command with quotes


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Dynamic command with quotes
# 1  
Old 03-24-2010
Dynamic command with quotes

I have a shell script which composes a dynamic command (DataStage application):

Code:
conn="/DS/Ascential/DataStage/DSEngine/bin " 
paramlist=" -run -jobstatus -wait -mode NORMAL -param JOB_ID=98246 -param PREVRUNDT='2010-03-20 18:00:00' -param CURRRUNDT='2010-03-21 18:00:00'" 
jobinfo=" APPPRJ Load_Target" 

$conn $paramlist $jobinfo

This does not work and says:

HTML Code:
Invalid arguments: dsjob -run 
                        [-mode <NORMAL | RESET | VALIDATE>] 
                        [-param <name>=<value>] 
                        [-warn <n>] 
                        [-rows <n>] 
                        [-wait] 
                        [-opmetadata <TRUE | FALSE>] 
                        [-disableprjhandler] 
                        [-disablejobhandler] 
                        [-jobstatus] 
                        [-userstatus] 
                        [-local] 
                        [-useid] 
                        <project> <job|jobid>

But it works if I have:

Code:
Code:
conn="/DS/Ascential/DataStage/DSEngine/bin/dsjob" 
jobinfo=" APPPRJ Load_Target" 

$conn -run -jobstatus -wait -mode NORMAL param JOB_ID=98246 -param PREVRUNDT='2010-03-20 18:00:00' -param CURRRUNDT='2010-03-21 18:00:00' -warn 50 $jobinfo

The list of parameters are dynamic so I'd like to put them in a string for readability of the code. I am really puzzled why it is not running when I am using variables.
The quoted strings PREVRUNDT='2010-03-20 18:00:00' are the culprit. When I store them in a variable, in this case $paramlist, the code does not work. But if I put them directly as in second code, they run well.
# 2  
Old 03-24-2010
Perhaps try...
Code:
paramlist=' -run -jobstatus -wait -mode NORMAL -param JOB_ID=98246 -param PREVRUNDT='\''2010-03-20 18:00:00'\'' -param CURRRUNDT='\''2010-03-21 18:00:00'\'''

# 3  
Old 03-24-2010
Thanks, Ygor, but the formed command becomes:
Code:
DS/Ascential/DataStage/DSEngine/bin -run -jobstatus -wait -mode NORMAL -param JOB_ID=98246 -param PREVRUNDT='\''2010-03-20 18:00:00'\'' -param CURRRUNDT='\''2010-03-21 18:00:00'\'' APPPRJ Load_Target

which is also invalid.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Printing double quotes in echo command

Please help me to use echo or printf type of command to print some value from variable within double quotes - I want to print the double quote ( " ") also. I tried #!/bin/bash VALUE=some_value echo '{"value" : "$VALUE"}' I was expecting the above script would produce .. {"value" :... (3 Replies)
Discussion started by: atanubanerji
3 Replies

2. UNIX for Beginners Questions & Answers

Please explain the use of quotes in awk command in below example-

Example: `abc.ksh | grep '^GLIS'| awk -F' ' '{print \$1}'`; (3 Replies)
Discussion started by: Tanu
3 Replies

3. Shell Programming and Scripting

Issue with quotes when running SQL command from within su -c

RHEL 6.2/Bash shell root user will be executing the below script. It switches to oracle user logs in using sqlplus and tries to run the below UPDATE statement. All the commands after su -c are enclosed in a single quote delimited by semicolon. The execution has failed because the quotes... (3 Replies)
Discussion started by: omega3
3 Replies

4. Shell Programming and Scripting

Issue with Single Quotes and Double Quotes for prompt PS1

Hi, Trying to change the prompt. I have the following code. export PS1=' <${USER}@`hostname -s`>$ ' The hostname is not displayed <abc@`hostname -s`>$ uname -a AIX xyz 1 6 00F736154C00 <adcwl4h@`hostname -s`>$ If I use double quotes, then the hostname is printed properly but... (3 Replies)
Discussion started by: bobbygsk
3 Replies

5. Shell Programming and Scripting

Shell Printf command , a little more dynamic..

A big hello to everyone tagged to this site of knowledge . This is the first post of mine and I am looking forward to an enjoyable stint in this forum where I get to know a lot of new ideas and share whatever knowledge (its not much though :) ) I have acquired throughout my career so far with... (4 Replies)
Discussion started by: kumarjt
4 Replies

6. Shell Programming and Scripting

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: CMD="SomeExecutable" # Parameter that has a space in-between PARAM1="TIMO 2" CMD_IN="--name=\"$PARAM1\"" CMD_OUT=`$CMD $CMD_IN` expected/required command execution:... (4 Replies)
Discussion started by: Timo
4 Replies

7. Shell Programming and Scripting

Shell script dynamic command

I need to run a shell script with dynamic command in it like # Begin script... mysql xx "select * from tab" | sed 's/\t/|/g' > GENERATED_20100304.txt the dynamic part is 20100304 which should be today's date, and it needs to run every day and create a new file with... (2 Replies)
Discussion started by: nuthalapati
2 Replies

8. Shell Programming and Scripting

ksh execute command containing double quotes

How do I execute a command containing a double quote ? I pass a variable to grep that contains spaces, so I need to quote it, but it does not work. #!/usr/bin/ksh set -x txt='"next to"' cmd="grep $txt ~dpearso5/file2" echo $cmd $cmd This is the error I get: + grep "next to"... (1 Reply)
Discussion started by: pearson05
1 Replies

9. Shell Programming and Scripting

too many quotes in command, generating error

I am trying to go through a file with hostnames and access those hosts remotely an excute the following to get the uid of user on each of the boxes.. but i have so many quotes.. its not working.. I fudged with the \ before certain quotes, but that was unsuccessful too... What am I missing? ... (4 Replies)
Discussion started by: julesdiane
4 Replies

10. Shell Programming and Scripting

Dynamic delimiter in cut command

hello.. my prob is as follows: i have to read from a file which may have different formats depending upon the delimiter used in the data of the file.now i need that the user input the delimiter.the input delimiter is stored in a variable and is used on cut command to retrieve necessary... (3 Replies)
Discussion started by: tej.buch
3 Replies
Login or Register to Ask a Question