The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Running UNIX Commands from C zainab High Level Programming 2 04-14-2008 08:35 PM
Problem in running bash shell commands on HP-UX machine abhishek0071 UNIX for Advanced & Expert Users 6 02-15-2008 11:30 AM
calling plsql function in a unix script cobroraj UNIX for Advanced & Expert Users 2 10-29-2007 07:06 PM
Running UNIX commands remotely in Windows box from Unix box – avoid entering password D.kalpana UNIX for Dummies Questions & Answers 1 04-20-2007 02:24 AM
running commands from script owijust Shell Programming and Scripting 2 01-09-2006 02:12 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-04-2006
Registered User
 

Join Date: Oct 2006
Posts: 6
Problem running plsql & unix commands in 1 script

Hi, I need help again. When I run this shell script, it only runs the unld_date.sql piece and exits. How can I structure this to run all the way to the end? When I don't have the unld_date.sql piece in here, everything runs fine from the date compare piece all the way to the end. Thanks in advance.


#!/bin/sh
#
sqlplus -s <<EOF username/password @/dir1/unld_date.sql > /dir2/dt_file.dat
exit 0
#
dt=`cat dt_file.dat`
today_dt=`date +%m%d%Y`
if [ "$dt" = "$today_dt" ]
then
#
# run pl/sql procedures 1 and 2
sqlplus -s <<EOF username/username @/dir3/code1.prc > /dir4/code1.log
@/dir3/code2.prc > /dir4/code2.log
exit
EOF
#
tail -10 /dir4/code1.log > log1.txt
tail -10 /dir4/code2.log > log2.txt
#
exit
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-04-2006
Registered User
 

Join Date: Jan 2005
Posts: 682
Am I missing something?

If this is really how your script reads, the "exit 0" is going to terminate your script every single time once "unld_date.sql" has been executed.

If it is working with "unld_date.sql" removed then you must also be removing "exit 0". The "exit 0" statement is not tied to the sqlplus command.

So the simple answer to your question is to remove "exit 0".
Reply With Quote
  #3 (permalink)  
Old 10-05-2006
Registered User
 

Join Date: Oct 2006
Posts: 6
I have taken out the "exit 0" line and it still gives me the same result. It stops right after the unld_date.sql and doesn't execute the rest. Thanks.
Reply With Quote
  #4 (permalink)  
Old 10-05-2006
Registered User
 

Join Date: Oct 2006
Posts: 3
Try EOF

where you have the exit 0, try putting EOF. Im a newb, but I think when you use <<EOF it expects anything between that and EOF to be commands within the program you started before the <<EOF.
Reply With Quote
  #5 (permalink)  
Old 10-05-2006
grial's Avatar
El UNIX es como un toro
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
Quote:
Originally Posted by redwjamz
where you have the exit 0, try putting EOF. Im a newb, but I think when you use <<EOF it expects anything between that and EOF to be commands within the program you started before the <<EOF.
I agree.
I think your script should read:
Code:
[...]
sqlplus -s <<EOF 
username/password @/dir1/unld_date.sql > /dir2/dt_file.dat
exit
EOF
[...]
Though it seems incomplete... I miss a "fi" and there are also an "exit" that, in my opinion, does not fit (the last one)...

Regards.
Reply With Quote
  #6 (permalink)  
Old 10-05-2006
Registered User
 

Join Date: Jan 2005
Posts: 682
Quote:
Originally Posted by siog
#!/bin/sh
#
sqlplus -s <<EOF username/password @/dir1/unld_date.sql > /dir2/dt_file.dat
exit 0
#
dt=`cat dt_file.dat`
today_dt=`date +%m%d%Y`
if [ "$dt" = "$today_dt" ]
then
#
# run pl/sql procedures 1 and 2
sqlplus -s <<EOF username/username @/dir3/code1.prc > /dir4/code1.log
@/dir3/code2.prc > /dir4/code2.log
exit
EOF
#
tail -10 /dir4/code1.log > log1.txt
tail -10 /dir4/code2.log > log2.txt
#
exit
Looking at the script again, the answer is clear. You are attempting to use a "here" document with the "<<EOF" statement. Your entire script is being pushed into sqlplus and when it reaches the "exit 0" command, it is exiting and the rest of your script isn't processed by sqlplus, which is why you don't see any error in you code1.log file.

You either need to add the "EOF" as stated by other posters or remove the "<<EOF". sqlplus will run the SQL at this point and let your script continue.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:14 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0