?
Solved

Syntax error in my script

Posted on 2013-05-10
7
Medium Priority
?
488 Views
Last Modified: 2013-05-10
I keep getting this error in my script:

"0403-057 Syntax error at line 6 : `<' is not matched."

I have gotten it before and the problem was EOF statement not being at the very beginning of a line. Not sure what is it this time. here is my script:

#!/usr/bin/ksh

(export ORACLE_SID=DBNAme
ORAENV_ASK=NO
. oraenv
sqlplus -s /nolog <<EOF
connect username/pwd
set lines 4000
set trimspool on
set feedback off
set pages 0

  SELECT fieldid, field1, field2 from my_view;
        exit;
EOF)|
while read line
do
        if [[ -n $line ]]
                then eval $line
                         printf "[%-10s]\t[%-25s]\t[%-15s]\n" "$fieldid" "$field1" "$field2"
        fi
done

exit 0

Open in new window

0
Comment
Question by:YZlat
7 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39156345
Sorry, I didn't see what you're really after.

I'll be back!
0
 
LVL 29

Accepted Solution

by:
MikeOM_DBA earned 1100 total points
ID: 39156429
Remove the () parenthesis:
. . . here:
export ORACLE_SID=DBNAme
ORAENV_ASK=NO
. . . .and here:
EOF |\
while read line
do . . .

Open in new window


PS: Notice the back-slash '\' after the pipe '|'
:p
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39156432
Generally, you can't place anything into the same line with the terminating EOF, except for a pipe..

You can process the output of preceeding commands along with the output of the "here" document using a pipe in the opening line (the one containing "<<EOF")

However, all processing must be done in one single line, because everything placed into subsequent lines would become part of the "here" document.

Example:

(export ORACLE_SID=DBNAme
ORAENV_ASK=NO
. oraenv
sqlplus -s /nolog <<EOF ) | while read line; do ...; done
connect username/pwd
set lines 4000
set trimspool on
set feedback off
set pages 0

  SELECT fieldid, field1, field2 from my_view;
        exit;
EOF

Since the line containing "while .. do ... done" could become very long I'd suggest creating a function to process the output.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39156511
Like this:

#!/usr/bin/ksh

function output_fn {
while read line
do
        if [[ -n $line ]]
                then eval $line
                         printf "[%-10s]\t[%-25s]\t[%-15s]\n" "$fieldid" "$field1" "$field2"
        fi
done
}

( export ORACLE_SID=DBNAme
ORAENV_ASK=NO
. oraenv
sqlplus -s /nolog <<EOF ) | output_fn
connect username/pwd
set lines 4000
set trimspool on
set feedback off
set pages 0

  SELECT fieldid, field1, field2 from my_view;
        exit;
EOF

exit 0

Open in new window

Please note that all this would only make sense if you indeed must process the output of the preceeding statement (". oraenv"). Otherwise MikeOM_DBA's solution is the one to use.
0
 
LVL 35

Author Comment

by:YZlat
ID: 39156533
MikeOM_DBA, Thanks!

What does backslash there do? It actually worked without the backslash
0
 
LVL 31

Assisted Solution

by:serialband
serialband earned 100 total points
ID: 39156810
Backslash means continue to the next line as if the newline doesn't exist.  It's used for helping you format long lines into more easily readable paragraphs.
0
 
LVL 35

Author Comment

by:YZlat
ID: 39156866
Thanks!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question