shell scripts do not exit once completed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting shell scripts do not exit once completed
# 8  
Old 08-22-2012
You should not have a space between << and EOF, The below sample code should run the procedure for you:

Code:
exec_sql=`sqlplus -S <<EXECPROC
ERS_SRC/ERS_SRC@ERS11G
set linesize 110 define off heading off feedback off serveroutput on format word_wrapped
whenever sqlerror exit 1
declare
begin
  proc_partition_mgmnt;
  dbms_output.put_line( '*** Finished procedure: proc_partition_mgmnt' );
exception
when others then
  dbms_output.put_line( '*** Error running procedure: proc_partition_mgmnt' );
  dbms_output.put_line( to_char( sqlcode ) || ' : ' || sqlerrm );
end;
/
exit 0
EXECPROC`

if [[ $? = 1 ]] then
  print `date "+%Y-%m-%d-%H.%M.%S"` "*** Error running procedure: proc_partition_mgmnt."
fi

if [[ $exec_sql = +(*** Error) ]] then
  print `date "+%Y-%m-%d-%H.%M.%S"` "*** Error running procedure: proc_partition_mgmnt."
  print `date "+%Y-%m-%d-%H.%M.%S"` "$exec_sql"
fi

# 9  
Old 08-23-2012
Hi
Scripts is working , there was a space but it works with the space as well . it doesn't work when trying to indent so i have used command as suggested. I have an issue since this database part is done in the middle of the scripts and it exit finally from the scripts, how can i make sure it does it part in data base and then execute rest of the scripts
# 10  
Old 08-23-2012
Quote:
Originally Posted by guddu_12
I have an issue since this database part is done in the middle of the scripts and it exit finally from the scripts, how can i make sure it does it part in data base and then execute rest of the scripts
hmm, you already know the routine: post an error message and we take a look at it. If there is no error message, start the script with "ksh -x <scriptname>" and show the relevant parts of the output (before you ask why redirection doesn't work: it goes to <stderr>).

In other words: D-E-B-U-G the script by S-E-A-R-C-H-I-N-G for the error instead of sitting there and asking us things we cannot answer (because we do not see what is on your monitor or harddisk).

My guess is that one of the "exit" statements meant for for exiting "sqlplus" is in fact directed at the shell, which would make the shell (and the script) exit. This is only an unproven suspicion, though.

I hope this helps.

bakunin
# 11  
Old 08-23-2012
Hi,

I have just removed the exit and it is working as expected. many thansks
# 12  
Old 08-23-2012
Amazing deduction by @bakunin when the "full script" in post #6 does not contain the word "exit" .

Noticed that $NEWDIR is referenced three times before it has a value. The script as posted cannot be working correctly.

Last edited by methyl; 08-23-2012 at 11:14 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[BASH] Script to manage background scripts (running, finished, exit code)

Heyas, Since this question (similar) occur every now and then, and given the fact i was thinking about it just recently (1-2 weeks) anyway, i started to write something :p The last point for motivation was... (17 Replies)
Discussion started by: sea
17 Replies

2. Homework & Coursework Questions

completed scripts

Does anyone know any websites where there are finished scripts, can be for anything Just want to copy and paste it and manipulate into something I could use. danke schon (0 Replies)
Discussion started by: cpcp1988
0 Replies

3. Shell Programming and Scripting

Java hangs even though shell script’s execution is completed

I'm trying to execute a script from within my java code. The execution of the script is over(it's pid is no more), but java is stuck on waitFor() method of the shell script process!. And yes, I'm reading output and error streams in 2 separate threads. Yes, they are being joined at the end(after... (0 Replies)
Discussion started by: pavanlimo
0 Replies

4. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies

5. Shell Programming and Scripting

check exit status of bg scripts

HI All, I am running one shell script, in that script i am calling 4 scripts in the background. abc.ksh & efg.ksh & xky.ksh & mno.ksh & please let me know, how could i find the success and failure of each script. i Cannot use $?, because i want to run all the scripts in parellel. ... (2 Replies)
Discussion started by: javeed7
2 Replies

6. Shell Programming and Scripting

How to pass parameter from sqlplus(procedure completed) to your shell script

if then # mail -s "Import failed file does not exist" sanjay.jaiswal@xyz.com echo "FILE does not exist" exit 1 fi echo "FILE EXIST" size=-1 set $(du /export/home/oracle/nas/scott21.dmp.gz) while do echo "Inside the loop" size=$1 set $(du... (1 Reply)
Discussion started by: sanora600
1 Replies

7. Shell Programming and Scripting

exit a shell script!!

could somebody tell me please how to exit a shell script: if then echo "No arguments detected" exit 1 fi ... echo "still there" # is displayed .. :-( (4 Replies)
Discussion started by: sami98
4 Replies

8. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

9. Shell Programming and Scripting

exit status of Invoking two or more scripts in background

I have a sript which is going to trigger other 3 scripts in background simultaneously for eg: Main Script:(main.sh) ----------- sh a.sh & sh b.sh & sh c.sh & How to catch the exit status and store it in a variable for all those three scripts in main script. Is there any other way of... (4 Replies)
Discussion started by: Omkumar
4 Replies
Login or Register to Ask a Question