Throwing Shell script's Stored procedure Exception Back to the Caller

75 Views Asked by At

i have a Shell Script A which calls Shell Script B which calls the Stored procedure within ISQL within it. The Exception in Shell Script B's Stored procedure has to be thrown back to the Original Shell Script A. Any idea how to do this?

2

There are 2 best solutions below

0
On BEST ANSWER

Here is the solution:

iSQL > $output_file
status='cat $output_file'
if [$status== "Login Failed"]; then
echo "Login Failed error"
elif  [$status== "Permission Denied"]; then
echo "Permission Denied error"
else [$status== "Connection error"]; then
echo "Connection Denied Error"
fi

 Or

$status='grep "permission denied" $tmp.txt | sed 'g/ /d' | cut -d":" -f2'
echo $status
8
On

@narasimhakulkami : What do you mean by throwing an exception in the context of a POSIX shell script? Aside from using kill for some suitable signal, which could be trapped by the receiving process, there is no exception mechanism available.

You could request the exception-catching process to provide its own PID in an environment variable and then do a kill on this PID, but of course you can not communicate any additional information with this signal (such as the exact exception message), and it would be a terrible design anyway.