Shell Script Dependencies other process

Hi

I have two queries regarding Shell script:

  1. Lets say there are three process, a.sh, b.sh, and c.sh. Now if I have to run c.sh iff a.sh gets over without any error/exception. what would be the code for that.

  2. Suppose our shell script is run after running a sql script in ORACLE. Is there any way in unix shell script which first runs sql query & then run the script. ( that too if no error/exeception is incurred in sql script ). IP userid & pasword of the database is known.

Please send me the code asap

Thanks & Regards

Pankaj

Hi Pankaj,

Answer of 2nd point is yes you can do that in shell script...have a look at code below..from this script you can check if err_message have some value in it then there is a oracle error.And if there is no value in that variable you can run the script....that can be done by IF THEN ELSE.......

Z=`sqlplus -s user/password@host <<eof
set serveroutput on;
declare
v_message varchar2(1000);
v_value number;
begin
select column into v_value from tablename where rownum<2;
EXCEPTION
WHEN OTHERS THEN
v_message := SQLERRM;
dbms_output.put_line(v_message);
END;
/
EXIT;
eof`
err_message=`echo "$Z" | grep "ORA-"`
echo $err_message

Hi

I tried to run with your script but its showing following output:

./database_connection.sh: line 1: sqlplus: command not found

sqlplus is not in path. Check ORACLE_HOME/bin is in path or not.

Regarding to point 1, the answer is also yes.
You only have to deal with exit codes. So if you give:

a.sh && c.sh

c.sh will only run if a.sh exited ok (0).
Regards.