Operating System - HP-UX
1827620 Members
3254 Online
109966 Solutions
New Discussion

update standard error message to oracle database

 
Aji Thomas
Regular Advisor

update standard error message to oracle database

Hi guys,

I have a backup script that redirects all the standard input, errors to a logfile. We are trying to implement, to update the same information within oracle database.

How can i get the errors to be updated as a record within my table.

I tried
err=$?

and update the value of $? to database, but this always returns 0

but within my log i can view errors like EXIT STATUS 122 etc.

I want to include this exact error message

please advice,
AJi
8 REPLIES 8
Steve Steel
Honored Contributor

Re: update standard error message to oracle database

Hi

*? is 0 because it changes every time


You need to play with putting the output to a variable and writing that

Something like
xx=$(/tmp/dol 2>&1;echo error $?)
echo $xx
/tmp/dol: fiel: not found. error 127

Then you can put xx into the errorlog and the database


Steve Steel

If you want truly to understand something, try to change it. (Kurt Lewin)
Aji Thomas
Regular Advisor

Re: update standard error message to oracle database

Hi,

Let me put a part of my backup script:

------------------------------------------
exec 1> $logfile
exec 2>&1

/usr/openv/netbackup/bin/bpbackup -p policy_prod -h hp1 -s default -t 0 -w /appcon1_nfs/PRD/archive/*.arch
SeqID=15
exitcode=$?
$updateinfo/updatestats.sql $SeqID $exitcode
------------------------------------------

All errors is logged into logfile properly.
But not goes to the database, it returns 0

Please advice how can i modify my script.

OldSchool
Honored Contributor

Re: update standard error message to oracle database

You've got:

SeqID=15
exitcode=$?
$updateinfo/updatestats.sql $SeqID $exitcode
------------------------------------------

The assignment of "SeqID" was successful, so the return code is 0.

Swap the exitcode and SeqID assignments and it should work
Aji Thomas
Regular Advisor

Re: update standard error message to oracle database

Yes i get the error number,
122 not EXIT STATUS 122,

But in my logifile, i get the entire status - EXIT STATUS 122

regards,
Aji
OldSchool
Honored Contributor

Re: update standard error message to oracle database

That is all you are going to get. The exitcode variable only knows the "status" returned by the prior process, in your case 122.

You will either have to look-up the error message text in the oracle's message catalogs, or parse it out of the log file if you want the full text
OldSchool
Honored Contributor

Re: update standard error message to oracle database

-- or --

if the message is always "EXIT STATUS "

try

exitcode='EXIT STATUS '$?
Aji Thomas
Regular Advisor

Re: update standard error message to oracle database

Hi,

the message is not always "EXIT STATUS "

it contains the error description also.

It is not oracle related, it is related to our backup software,

Thanks in advance,
AJi
Steve Steel
Honored Contributor

Re: update standard error message to oracle database

Hi

tail the logfile at the end and write that to the database


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)