LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-07-2014, 10:08 AM   #1
nivashcu123
LQ Newbie
 
Registered: Nov 2014
Posts: 2

Rep: Reputation: Disabled
Error while running sql script which has OS commands.


Hi,

I am new to shell scripting. I need help at a point. Please find below piece of code that is part of a SQL script.

-----------
set head off

spool tempfile.bat
select distinct 'echo '||ath_prefix||basepath||ath_suffix prod_top
from fnd_application
where application_id in (:appl_id1, :appl_id2, :appl_id3, :appl_id4, :appl_id5);
spool off

host chmod 777 tempfile.bat
host tempfile.bat >> &output_file

host echo '' >> &output_file
host echo 'Custom Library Information' >> &output_file
host echo '==========================' >> &output_file
host echo '' >> &output_file
----------------

After reaching this point final output file giving error messages below

/bin/bash: -c: line 0: syntax error near unexpected token `newline'
/bin/bash: -c: line 0: `tempfile.bat >> '

/bin/bash: -c: line 0: syntax error near unexpected token `newline'
/bin/bash: -c: line 0: `echo '' >> '

/bin/bash: -c: line 0: syntax error near unexpected token `newline'
/bin/bash: -c: line 0: `echo 'Custom Library Information' >> '

/bin/bash: -c: line 0: syntax error near unexpected token `newline'
/bin/bash: -c: line 0: `echo '==========================' >> '

/bin/bash: -c: line 0: syntax error near unexpected token `newline'
/bin/bash: -c: line 0: `echo '' >>

What can be the reason?.
 
Old 11-13-2014, 07:26 AM   #2
nivashcu123
LQ Newbie
 
Registered: Nov 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
Any input is helpful..

Why below errors are coming?.. Code can be find above.

-----------------------------------------------------------------------------------
/bin/bash: -c: line 0: syntax error near unexpected token `newline'
/bin/bash: -c: line 0: `tempfile.bat >> '

/bin/bash: -c: line 0: syntax error near unexpected token `newline'
/bin/bash: -c: line 0: `echo '' >> '

/bin/bash: -c: line 0: syntax error near unexpected token `newline'
/bin/bash: -c: line 0: `echo 'Custom Library Information' >> '

/bin/bash: -c: line 0: syntax error near unexpected token `newline'
/bin/bash: -c: line 0: `echo '==========================' >> '

/bin/bash: -c: line 0: syntax error near unexpected token `newline'
/bin/bash: -c: line 0: `echo '' >>
------------------------------------------------------------------------------------------
 
Old 11-13-2014, 11:38 AM   #3
rigor
Member
 
Registered: Sep 2011
Posts: 212

Rep: Reputation: Disabled
Hi nivashcu123!

It seems as if there might be a number of diverse elements in your post that might need some explaining.

Just FYI, this forum is a Linux forum, but you seem to be using a .bat file which would typically be more for use with MS-DOS or MS-Windows. You didn't way what OS you are using. If you are working with either MS-DOS or MS-Windows, then I believe you would want a non-Linux forum within LQ, such as:

Non-*Nix Forums > Programming

If instead you are working with Linux, then this might be the appropriate forum for your question.

AFAIK, when no one had responded to your question, your question was on a list of posts with zero replies; yet when you added a second item to the thread you started, I believe you knocked your question off that list, potentially making it less likely that you would get a response to your own question.

You didn't say what database engine, or interface to the engine you are using. Are you using SQLPlus with Oracle?

Different shells have different syntax, and you didn't mention which shell you are using.

IF, you are using SQLPlus with Oracle, with BASH under Linux, and you are trying to append both stdout and stderr to the file output_file then you might want:

Code:
echo '' &>> output_file
If some or all of my guesses are incorrect, please provide the missing details, to help us, help you.

HTH.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Running sudo commands from a script oneindelijk Linux - Newbie 4 12-11-2012 03:42 AM
Issue in running commands in expect script from shell script yadvinder Programming 0 05-31-2012 05:07 AM
[SOLVED] SQL commands inside bash script XardasCZ Linux - Server 1 05-05-2011 11:08 AM
[SOLVED] Running SQL commands from within bash chirayu11 Linux - Newbie 6 08-02-2010 07:38 AM
running sql script under sqlite3 miamagoo Linux - Newbie 1 06-16-2010 10:23 AM


All times are GMT -5. The time now is 06:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration