While loop subshell problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting While loop subshell problem
# 1  
Old 04-17-2013
While loop subshell problem

People,

Here is my code
Code:
while read ln
do
xyz=$(echo $ln/$val1*100-100|bc -l|xargs printf "%1.0f\n")
if [ "$xyz" -le -50 ] && [ "$xyz" -ne 0 ]; then
                iam="YELLOW"
fi
done <<< "$(grep "^[0-9]" $TMPOUT)"

where $TMPOUT is a flat file which contains a set of values.

Whilst executing the above, I get an error
Code:
ABC.ksh: line 136: unexpected EOF while looking for matching `"'
ABC.ksh: line 141: syntax error: unexpected end of file

Where is the problem, how i can correct it. Please help, thanks.
# 2  
Old 04-17-2013
One reason could be, you need to escape the asterisk:

Code:
xyz=$(echo $ln/$val1\*100-100|bc -l|xargs printf "%1.0f\n")

Guru.
# 3  
Old 04-17-2013
You are trying to put double quotes inside double quotes, try using single quotes:

Code:
'^[0-9]'

# 4  
Old 04-17-2013
The double quotes usage is fine. That's one of the benefits of the $(...) command substitution syntax. The code within the substitution does not have to worry about colliding with anything in its surroundings.

I suspect the error lies elsewhere. The OP is only showing us 7 lines but the diagnostic messages indicate that there are well over a 100 in the script.

To the OP, line numbers in error messages can be misleading. I suggest posting the entire script.

Regards,
Alister
# 5  
Old 04-17-2013
Ah, yes, good point. A runaway quote can eat up all the lines after it until it finds another quote.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Infinite "while" loop subshell loses current date variable

I have a simple script to log network connectivity to a set of systems. However, as expected the date appended to the log never changes because the new variable is lost when the loop starts again. Can someone clue me in on how to get around this issue? #!/bin/bash LOG=/tmp/netlog... (3 Replies)
Discussion started by: woodson2
3 Replies

2. Shell Programming and Scripting

Help sending mail through subshell

Hey I have a shell script that is like this: ( echo "hi!" ##DO SOMETHING )&( sleep 5 ##EMAIL RECIPIENTS VARs ERECIPIENT3="email.com" echo "Connection on status: is Down"|mail -s "Subject:" ${ERECIPIENT3} kill -- -$$ ) This isn't working anyone know why? mail won't go out from... (12 Replies)
Discussion started by: mo_VERTICASQL
12 Replies

3. Shell Programming and Scripting

Executing a command in subshell

Hi All, I am trying to create a shell script which runs on my linux machine. The requirement is so that, ade createview xyz -> this steps creates a view ade useview xyz -> we are entering inside the view ade begintrans -> begin a transaction My script has following code : lets say... (2 Replies)
Discussion started by: Dish
2 Replies

4. Shell Programming and Scripting

Basename in subshell

Hi All, I would like to improve my bash scripting skill and found a problem which I do not understand. Task is to search and print files in directory (and subdirecories) which contains its own name. Files can have spaces in name. This one works fine for files in main directory, but not for... (4 Replies)
Discussion started by: new_item
4 Replies

5. Shell Programming and Scripting

While loop subshell problem

Hi, I have the below script while true; do read -p "Please enter schema password: " -s -e pswd1 echo read -p "Please retype schema password: " -s -e pswd2 echo && { echo -e "password mismatch.\n"; continue; } validateOraclePassword $pswd1... (2 Replies)
Discussion started by: varu0612
2 Replies

6. Shell Programming and Scripting

redirect stdout and stderr to file wrong order problem with subshell

Hello I read a lot of post related to this topic, but nothing helped me. :mad: I'm running a ksh script with subshell what processing some ldap command. I need to check output for possible errors. #!/bin/ksh ... readinput < $QCHAT_INPUT |& while read -p line do echo $line ... (3 Replies)
Discussion started by: Osim
3 Replies

7. Shell Programming and Scripting

getopts in a subshell

Hello, I've a little problem with one of my ksh scripts and I manage to narrow it to the script here: #!/bin/ksh writeLog() { paramHandle="unknown" OPTIND=1 while getopts :i: option $* do case $option in i) paramHandle=${OPTARG} ;; esac done echo... (2 Replies)
Discussion started by: Dahu
2 Replies

8. Shell Programming and Scripting

Killing a subshell

I am calling a script from with another script and reading its output one line at a time (using <childscript> | while read line) in the parent script. If the output exceeds a predefined number of lines I want to kill the child shell from within the parent shell. I decided to print the process ID... (2 Replies)
Discussion started by: slash_blog
2 Replies

9. Shell Programming and Scripting

Passing arguments to the subshell

I have a shell script which is invoked by passing an argument. The outer shell script calls another subshell and I want the argument passed down to flow down to the subshell. E.g Invoking a shell ======>> abc_refresh.ksh NM Below is the content of abc_refresh.ksh Value1=$1... (7 Replies)
Discussion started by: Mihirjani
7 Replies

10. Shell Programming and Scripting

Subshell Question

The profile of the user is empty. Then before I run the script I want I run a parameter file that populates the variables for oracle. ORACLE_HOME ORACLE_BASE ORACLE_SID PATH etc ... But it seems that these variables are not making it to the shell I am in because when I do an echo on... (6 Replies)
Discussion started by: lesstjm
6 Replies
Login or Register to Ask a Question