Formating error message


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Formating error message
# 1  
Old 03-27-2007
Java Formating error message

Hi Unix Punters,

Iam calling one PL/SQL script 'a.sql' through a shell script 'a.sh' and capturing
the error message generated during execution of a.sql and storing this message in one log file 'a.log'.

a.sh:-

#!/usr/bin/ksh

RESULT=`sqlplus -s username/password@database <<!
@a.sql
!`
echo $RESULT >> a.log



a.sql:-

Set serveroutput on
WHENEVER SQLERROR EXIT 1
WHENEVER OSERROR EXIT 2

BEGIN
insert into aaa (sal) (select name from bbb);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE ('Errored while inserting to the table aaa');
RAISE;
END;
/
EXIT SUCCESS


The scripts 'a.sh' and 'a.sql' are present in the below location.

/export/home/ITC_rlok>ls -lrt
total 16
drwxrwxrwx 4 ITC_rlok ITC 512 Dec 7 05:09 CR11
drwxrwxrwx 10 ITC_rlok ITC 512 Dec 22 14:21 RMIS
drwxrwxrwx 7 ITC_rlok ITC 512 Feb 6 13:18 TEMP
drwxrwxrwx 5 ITC_rlok ITC 512 Feb 8 08:32 CRED0001
drwxrwxrwx 2 ITC_rlok ITC 512 Mar 13 09:51 TEST
drwxrwxrwx 3 ITC_rlok ITC 512 Mar 27 11:27 SLLD0005
-rwxrwxrwx 1 ITC_rlok ITC 271 Mar 27 12:13 a.sql
-rwxrwxrwx 1 ITC_rlok ITC 90 Mar 27 12:17 a.sh

Now Iam executing the program 'a.sh'.

/export/home/ITC_rlok>a.sh
Errored while inserting to the table aaa BEGIN a.sh a.sql CR11 CRED0001 RMIS SLLD0005 TEMP TEST ERROR at line 1: ORA-01722: invalid number ORA-06512: at line 6

Iam getting the required error message. The problem here is, the error message is also containing other file/directory name which are present along with 'a.sh'.
I dont want to display the file/directory names along with error message. Please help me to avoid this problem.

I need only the error message as per below order:

Errored while inserting to the table aaa
ERROR at line 1: ORA-01722: invalid number
ORA-06512: at line 6


Thanks in advance,
Mysore Ganapati.
# 2  
Old 03-27-2007
Quote:
RESULT=`sqlplus -s username/password@database <<!
Try:

sqlplus -s username/password@database @a.sql >> a.log 2>&1
# 3  
Old 03-27-2007
PHP no luck :-(

no luck, result is same Smilie

/export/home/ITC_rlok>cat a.log
Errored while inserting to the table aaa BEGIN a.log a.sh a.sql CR11 CRED0001 RMIS SLLD0005 TEMP TEST ERROR at line 1: ORA-01722: invalid number ORA-06512: at line 6

Any other option please?
# 4  
Old 03-27-2007
Quote:
Originally Posted by ganapati
no luck, result is same Smilie

/export/home/ITC_rlok>cat a.log
Errored while inserting to the table aaa BEGIN a.log a.sh a.sql CR11 CRED0001 RMIS SLLD0005 TEMP TEST ERROR at line 1: ORA-01722: invalid number ORA-06512: at line 6

Any other option please?
Try this:

sqlplus -s user/password@database @a.sql 1>>a.log 2>&1

Also, make sure you "zero" your a.log first and try fresh.
# 5  
Old 03-28-2007
Hammer & Screwdriver Worked fine

Smilie Thanks Deal Nodeal,
Below code worked for me.

err_mesg=`sqlplus -S $ORA_USERID_PWD << !
@a.sql
!`
if [ $? -ne 0 ]
then
echo "$CTM_JOBNAME Error " >> $LOGFILE 2>&1
echo "Error message : $err_mesg" >> $LOGFILE 2>&1
exit 1
fi


Thanks to all.

With Regards,
Ganapati.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Red Hat

formating a USB which is throwing error write delayed

Hello, while i was saving a web file directing on to usb location there was some network problem which result in error WRITE DELAYED on windows xp. so pen drive is not getting completely formated(show as Windows was unable to complete format).From then onwords it is not allowing to copy... (0 Replies)
Discussion started by: amarnathbasis8
0 Replies

2. UNIX for Dummies Questions & Answers

What does this Error Message Mean

Hi I found the following error message in my logs: warning: /etc/hosts.deny, line 6: can't verify hostname: getaddrinfo(localhost) didn't return ::ffff:222.255.28.33 What is the error message trying to indicate? That there is a problem with line 6 (2 Replies)
Discussion started by: mojoman
2 Replies

3. UNIX for Dummies Questions & Answers

What does this error message mean?

I was reviewing logs and I got this error message in /var/log/messages: Did not receive identification string from (IP ADDRESS) What does it mean? (6 Replies)
Discussion started by: mojoman
6 Replies

4. UNIX for Dummies Questions & Answers

Error Message

I keep getting an error message in a script im writing, this line is allways pointed out. if and this is the message i keep getting. line 32: [: 8: unary operator expected Whats wrong with it? Please Help. (5 Replies)
Discussion started by: chapmana
5 Replies

5. Shell Programming and Scripting

Error message

I am new to scripting. I am using the following script . BART.dat contains the string 'Y' . #!/bin/ksh cd /work/TCI/data_out file=`cat BART.dat` echo "$file" if ; then echo "true" fi When i am executing the above script i am getting the following error ./s.ksh: : not found ... (2 Replies)
Discussion started by: ammu
2 Replies

6. UNIX for Advanced & Expert Users

error message

I get this error message as soon as i log in -bash: /usr/local/software/.../vni/CTT6.0/ctt/bin/lopt64.sh: No such file or directory I looked into the etc/profile but there are no lines sourcing this file. And there is no lopt64.sh in the directory vni/.../bin I couldn't fogure out what... (4 Replies)
Discussion started by: dsmv
4 Replies

7. AIX

Error Message with ls

When I try to list a directory that I have been using rsync to copy, I now am getting the following message. root # ls -alt /directory ls: /directory: Value too large to be stored in data type. total 0 I can change directory and list the contents of directories within /directory, but I... (2 Replies)
Discussion started by: sallender
2 Replies

8. Solaris

lp error message

Both of these messages are filling up the /var/adm/messages files on these two Sun boxes, goober and gomer. The print server is called gold. Jul 31 03:15:40 gold bsd-gw: request to ma28084.Solaris (unknown printer) from goober Jul 31 03:16:39 gold bsd-gw: request to ma28084.Solaris (unknown... (1 Reply)
Discussion started by: antalexi
1 Replies

9. UNIX for Advanced & Expert Users

Error message

I'm getting an error - symbol referencing errors. No output written to, etc Can anybody tell me why this is? (2 Replies)
Discussion started by: Dan Rooney
2 Replies
Login or Register to Ask a Question