![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| run shell script from oracle store procedure | arnabb4u | Shell Programming and Scripting | 8 | 08-16-2006 12:16 PM |
| Capture Oracle return code in shell script | Vikas Sood | Shell Programming and Scripting | 1 | 05-22-2006 05:32 PM |
| how to return an array of elements from oracle to shell script | satyakiran | Shell Programming and Scripting | 3 | 08-02-2005 09:57 AM |
| updating a column in oracle table using shell script | sveera | Shell Programming and Scripting | 3 | 05-09-2005 01:01 PM |
| update a oracle table using shell script | ann_124 | Shell Programming and Scripting | 2 | 12-18-2004 07:24 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
||||
|
Hi friends,
I have to do the following things : 1) there should be a shell script returning the returning the return code of the script. and i have to add some more details like on which machine is has run , at what time and other details and then using plsql i have to add a row to Oracle table. 2) then i have to write another script which will monitor the table for the machine_name and gets the job status of the earlier shell script .and depending on the success(0) or failure(1) (which are the status codes) a mail has to be sent to the respective groups. Do i have to use SQLLOADER or is there any other way ? how to i input the return code of the shell script into the table ? Please help thanks in advance Veera |
|
||||
|
Hi friends,
I am able to insert the return code of some unix job into the database with storing the return code into some variable and then using that value in the insert statement. But now i have to write a trigger which will be fired when ever there is an update or insert of the table. Then based on the value in the status_code( return code of the script) , the trigger has to send a mail to soem group. Please help thanks in advance Veera |
|
||||
|
Quote:
Script 1: Code:
#! /bin/ksh
...
myscript # Call your script
RC=$? # Get your script's return status
HOST=$(uname -n)
# Call SQL*Plus
sqlplus username/password <<EOF
BEGIN
INSERT INTO status_table VALUES('${HOST}', '${RC}');
COMMIT;
END;
/
EOF
or
sqlplus username/password <<EOF
BEGIN
your_plsql_sp('${HOST}', '${RC}');
END;
/
EOF
Code:
#! /bin/ksh
...
# Loop forever
while :
do
{
sqlplus -S username/password <<EOF
set heading off feedback off serveroutput on
DECLARE
STATUS_CODE VARCHAR2(50) := 'none';
BEGIN
-- Attempt to find the status for the specified host
SELECT 'StatusCode:' || 0
INTO STATUS_CODE
FROM status_table
WHERE hostname = '${HOST}';
-- Found it, print the status and drop out of PL/SQL block
DBMS_OUTPUT.PUT_LINE (STATUS_CODE);
EXCEPTION
-- No status yet, drop out with a -1 code
WHEN NO_DATA_FOUND THEN
SELECT 'StatusCode:-1'
INTO STATUS_CODE
FROM dual;
DBMS_OUTPUT.PUT_LINE (STATUS_CODE);
END;
/
EOF
} | while read LINE # Find out what SQL*Plus says
do
# Look for the status message
if print $LINE | /usr/xpg4/bin/grep -iq StatusCode
then
# Parse out the actual status code and break from inner loop
STATUS_CODE=$(print $LINE | awk -F: '{print $2}')
break
fi
done
# If status code is not -1, break out of endless loop
if [ ${STATUS_CODE:=-1} -ge 0 ]
then
break
fi
# Otherwise, continue monitoring the status table
print "Still waiting for status..."
sleep 5
done
if [ ${STATUS_CODE} -eq 0 ]
then
maix -s Success...
else
maix -s Sorry, it failed...
fi
If you really want to use a trigger then you are going to have to utilize UTL_SMTP. Thomas Last edited by tmarikle; 05-04-2005 at 01:38 PM.. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|