#!/bin/sh # # $Id: oerr 28-aug-2001.15:35:03 mkrohan Exp $ # Copyright (c) 1994, 2001, Oracle Corporation. All rights reserved. # # Usage: oerr facility error # # This shell script is used to get the description and the cause and action # of an error from a message text file when a list of error numbers are passed # to it. It supports different language environments and errors from different # facilities. # # # Turn on script tracing if, requested [ "$ORACLE_TRACE" = "T" ] && set -x # # If ORACLE_HOME is not set, we will not be able to locate # the message text file. if [ ! "$ORACLE_HOME" ] then echo "ORACLE_HOME not set. Please set ORACLE_HOME and try again." 1>&2 exit 1 fi # # Ignore user locale LC_ALL=C export LC_ALL # # Definition script "constants" Facilities_File=$ORACLE_HOME/lib/facility.lis # # Check script usage if [ "$#" != "2" ] then exec 1>&2 echo 'Usage: oerr facility error' echo echo 'Facility is identified by the prefix string in the error message.' echo 'For example, if you get ORA-7300, "ora" is the facility and "7300"' echo 'is the error. So you should type "oerr ora 7300".' echo echo 'If you get LCD-111, type "oerr lcd 111", and so on.' exit 1 fi # # Pickup the command line arguments Facility="$1" Code="$2" # # Get the facility information from the oerr data file Fac_Info=`grep -i "^${Facility}:" $Facilities_File 2> /dev/null` if [ $? -ne 0 ] then echo "oerr: Unknown facility '$Facility'" 1>&2 exit 1 fi # # Parse the components from the Fac_Info string into Shell variables eval `echo "$Fac_Info" | awk -F: '{ if (index ($3, "*") == 0) printf ("Facility=%s\n", $3); else printf ("Facility=%s\n", $1); printf ("Component=%s\n", $2); }'` if [ -z "$Facility" -o -z "$Component" ] then echo "oerr: Invalid facilities entry '$Fac_Info'" 1>&2 exit 1 fi # # The message file searched is always the US English file Msg_File=$ORACLE_HOME/$Component/mesg/${Facility}us.msg if [ ! -r $Msg_File ] then echo "oerr: Cannot access the message file $Msg_File" 1>&2 exit 1 fi # # Search the message file for the error code, printing the message text # and any following comments which should give the cause and action for # the error. awk "BEGIN { found = 0; } /^[0]*$Code/ { found = 1; print ; next;} /^\/\// { if (found) { print; } next; } { if (found) { exit; } }" $Msg_File exit 0