Command substitution error in linux.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Command substitution error in linux.
# 1  
Old 11-29-2011
Command substitution error in linux.

Hi All
I have a code like in a script
Code:
        echo 'export '${colname}'='"'"`db2 -x "SELECT TRIM(${colname}) FROM ${DB_SCHEMA_NAME}.ETL_ALERT_CONFIG"'`"'" >> ${CM_CONFIG_FILE}

After execution of the script its throwing me error at this code like

Code:
/data/ds/dpr_ebicm_uat/etl/cm3_0/scripts/shell/cm_alert.sh: command substitution: line 81: unexpected EOF while looking for matching `''

Could you all please help me in why this error is coming as its screwing the entire script.
# 2  
Old 11-29-2011
As the message already tells you - you have 7 single quotes in this line, so one seem to be missing; just count them. There seem to be some of them that could be left out anyway or escaped different at least. Would also help readability.
# 3  
Old 11-30-2011
Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command option substitution?

Hi folks, I totally dislike asking questions in forums but this one eats up to much of my time I need to spend on other topics. I have a shell-script in which I call a terminal. I want to invoke bash inside the terminal and print a message inside bash with aid of a here document. See... (7 Replies)
Discussion started by: bluntroller
7 Replies

2. UNIX for Dummies Questions & Answers

Environment variable substitution in Linux make

I know that I can do this in bash ver=${VERSION:-$DEFVERSION} so ver is $VERSION if it's set but $DEFVERSION if $VERSION isn't set I want to do the same thing as a macro in a Makefile and can't get it to work - maybe something like... VER=$(shell ${$(VERSION):-$(DEFVERSION)}) Any help... (1 Reply)
Discussion started by: JerryHone
1 Replies

3. Shell Programming and Scripting

Regarding command substitution

Oracle Linux 5.6, 64-bit Given the following snippet wrkvar=`sqlplus -s / as sysdba <<EOF set echo off feedback off head off trimsp on select count(*) from v\$parameter where name in ('db_file_name_convert','log_file_name_convert') and value is not null; EOF` echo wrkvar=$wrkvarProduces... (2 Replies)
Discussion started by: edstevens
2 Replies

4. Shell Programming and Scripting

Linux Command Error for nawk command

Hi All We are migrating our projects from unix environment to linux. I tried running a install script which sets up my project, i.e. the directory structure and all. But in the middle of the script i started receiveing following error : nawk: command not found . So i need to know which... (1 Reply)
Discussion started by: vee_789
1 Replies

5. UNIX for Advanced & Expert Users

Help with command substitution in C program

Hi, I want to know if there's a cleaner way for assigning output of a unix command to a variable in C program . Example : I execute dirname fname and want the output to be assigned to a variable dname . Is it possible . I knew u can redirect the output to a file and then reread assigning... (5 Replies)
Discussion started by: royalbull
5 Replies

6. UNIX for Dummies Questions & Answers

read command - using output from command substitution

Hey, guys! Trying to research this is such a pain since the read command itself is a common word. Try searching "unix OR linux read command examples" or using the command substitution keyword. :eek: So, I wanted to use a command statement similar to the following. This is kinda taken... (2 Replies)
Discussion started by: ProGrammar
2 Replies

7. UNIX for Dummies Questions & Answers

sed insert command and variable expansion/command substitution

I know this script is crummy, but I was just messing around.. how do I get sed's insert command to allow variable expansion to show the filename? #!/bin/bash filename=`echo $0` /usr/bin/sed '/#include/ { i\ the filename is `$filename` }' $1 exit 0 (8 Replies)
Discussion started by: glev2005
8 Replies

8. UNIX for Dummies Questions & Answers

Command substitution within an echo

I'm trying to get this to work and I'm not really sure how to do it. echo $x | awk '{print $NF}' MODIFIEDThe output I'm trying to get should look like: dir1 MODIFIED Where dir1 will be the result of: $x |awk '{print $NF}'I'm sure there's something I'm supposed to put around that part... (3 Replies)
Discussion started by: ewoods
3 Replies

9. Shell Programming and Scripting

Difference between "Command substitution" and "Process substitution"

Hi, What is the actual difference between these two? Why the following code works for process substitution and fails for command substitution? while IFS= read -r line; do echo $line; done < <(cat file)executes successfully and display the contents of the file But, while IFS='\n' read -r... (3 Replies)
Discussion started by: royalibrahim
3 Replies

10. Shell Programming and Scripting

Substitution of last command

"Is there any substituation of last command or script syntax which can be used as a user. As far I know the "last" command is being used to display information about previous logins. A member of adm group or the user adm can execute it only. Thanks in advance for your usual help. Ghazi (6 Replies)
Discussion started by: ghazi
6 Replies
Login or Register to Ask a Question