Terminate initially if error found...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Terminate initially if error found...
# 8  
Old 01-17-2011
Of course, all the child scripts must know how to exit not zero on any sort of error, a recursive search for unexpected exits and unchecked conditions.
# 9  
Old 01-18-2011
I tried with the pre-script error processing, with "sed -e". Looks like its working fine, but for what ever case (0 ,2, 4), it should send the e-mail to the user, stating the result.
But as per the script, its not sending e-mail for any failure, but the user is receiving the e-mail for any success.

Can you please look at the sub-script attached to this e-mail and let me know as to where i am going wrong.
# 10  
Old 01-18-2011
No, shell command set -e, nothing to do with sed, the stream editor.
# 11  
Old 01-18-2011
I got rid of set -e command.

Now i am facing a new issue.
When i execute the shell script, it just shows me blank with no progress.

-bash-3.00$ ./sqlldrclaims_backup_new.sh
Password:
SQL*Loader: Release 11.2.0.1.0 - Production on Tue Jan 18 10:26:39 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

When i do "ps -ef" i see this
Code:
zx01324 25166 25150   0 10:12:25 pts/1       0:00 sqlldr zx01182 control=/space/dbexport/PHR/control/claims.ctl log=/space/dbexpo

Can anyone explain to me as to what's going on, as it used to load the data, but now,, its runs at the background.
# 12  
Old 01-18-2011
https://www.unix.com/shell-programmin...e-files-5.html
In you previous threads on this script from a couple of months ago I don't think we found out what Shell you were using.

Anyway, one of your problems may be the "set -e".
Code:
         -e   Execute the ERR trap, if set, and exit if a command has a
                nonzero exit status, and is not part of the compound list
                following a if, until, or while keyword, and is not part of
                an AND or OR list, and is not a pipeline preceded by the !
                reserved word.  This mode is disabled while reading
                profiles.

Good idea to put a line in after saving $rc to display the value. This will tell you if the line is ever executed when the preceding command returns a non-zero exist status.
Code:
rc=$?
echo "The value of rc = $rc"

# 13  
Old 01-18-2011
You can set -ex and get a progress report as child processes are started. However, if there is information to catch in the return code, you need to capture $? in another variable, IMMMEDIATELY, before it is overwritten by your error handling code.

But that is your choice, in terms of error handling architecture. The child script could log everything and just return 0 or 1, so when testing a child, you do not need the parent or a hand coded echo $? to see the result (and you might overlook that in a quick test). Logging should be clear, so it is good to have the parent log just say 'parent started at this time, started child at this time with these arguments, child can write log location, child ended good or bad at this time, parent ended at this time. This way, clutter can be logged down at the leaf level, and in some case rejects or errors are potentially large enough to go in a specific separate file, not the main log, but with the side log path and its stats in the main log. If you reuse the same log path, there should be internal start/end headers and code to prevent two runs at once.

You, too, deserve good error checking, handling, logging. Think of it as a real product, just like processed data. When x runs, it owes me an output file and a log of happy ending or a log of why not, all the time, 100%, unity, 1.0 probability!

Last edited by DGPickett; 01-18-2011 at 12:47 PM..
# 14  
Old 01-18-2011
Methyl,

I am sorry for not replying back to you as to what Shell i am using.

The answer is :

Its "bash"
Code:
-bash-3.00$ echo $0
-bash

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Want to terminate command execution when string found in the command output

Hi Experts, I am very much new to linux scripting, I am currently working on reducing my manual work and hence writing a script to automate few task. I am running below command to snmpwalk the router.. snmpwalk -v 3 -u WANDL_SU -a MD5 -A vfipmpls -x DES -X VfIpMpLs -l authPriv... (19 Replies)
Discussion started by: Hanumant.madane
19 Replies

2. UNIX for Dummies Questions & Answers

Terminate a port connection

I have executed a command which has ports that have to be assigned. then I deleted the files. Now I need to reinstall the command. but it says the ports are not free How to terminate the port connections and reinstall in solaris unix ---------- Post updated at 09:07 PM ----------... (7 Replies)
Discussion started by: sriki32
7 Replies

3. Solaris

mcrypt module is not initially loaded with php

Hi I'm trying to do an upgrade for one application and whenever I run the upgradre the program shows the error that mcrypt module is not initially loaded with php. My server is running xampp 0.9 and I know this library of mcrypt is already installed. I changed the php.ini file in order to... (0 Replies)
Discussion started by: dahr
0 Replies

4. Solaris

Application terminate

OS : Solaris X86 gcc version 3.4.6 when i run my application, C with Motif application crashed and formed core. I collected the truss ouput. Incurred fault #6, FLTBOUNDS %pc = 0xFE8B35CD siginfo: SIGSEGV SEGV_MAPERR addr=0x00000275 Received signal #11, SIGSEGV siginfo:... (2 Replies)
Discussion started by: satish@123
2 Replies

5. Programming

command to terminate

hi all how to terminate command eecution process. can you please show me the way thank you (2 Replies)
Discussion started by: munna_dude
2 Replies

6. Shell Programming and Scripting

Terminate process

We have a system user "oracle_usr" always run some process in the system , but sometimes , these processes will not stop automatically until we terminate the process , can suggest the method how to terminate the process that is run by "oracle_usr" and run over 10 minutes ? thx (5 Replies)
Discussion started by: ust
5 Replies

7. Shell Programming and Scripting

terminate process

I want to have a script to terminate the system process that generated by user oracle_usr and have already processed for over 10 minutes , could suggest the script ? thx (1 Reply)
Discussion started by: ust
1 Replies

8. Shell Programming and Scripting

terminate the process

In my system , there are a system user "cronusr" , it is mainly to run the crontab job in the database .Sometimes the cronjob process will be failure ( due to some reason ) so that many cronusr process are in the system , it affect other process in the system , I want to have a script that can... (2 Replies)
Discussion started by: ust
2 Replies

9. Shell Programming and Scripting

Terminate session on completing script

Hai all.. How do i terminate my telnet session automatically when my java applicatiion exits. i have a file run which executes my java application and takes care of all class and library path settings prior to the execution. I would like to terminate my session when my application exits. The... (4 Replies)
Discussion started by: deepsteptom
4 Replies

10. Shell Programming and Scripting

How to terminate a tail -f

I am developing a script with a tail -f in it. My problem is how to terminate it and execute the next line. (4 Replies)
Discussion started by: DonVince
4 Replies
Login or Register to Ask a Question