ksh errors out in SQL database with 'exit 45'

Solution Unverified - Updated -

Issue

The exit code from sqlplus is echoed to &4 and then using 4>&1 so that the STATUS variable ends up being assigned the exit code from sqlplus. It is then sanity-checked to make sure that it has a value (hopefully 0). If it doesn't have a value the script will exit with 45. Below is noticed errors:

SQL> SET ECHO OFF;
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters and Automatic Storage Management options
+ echo 0
+ 1>& 4
+ STATUS=''
+ [ 0 -ne 0 ]
+ [ -z '' ]
+ exit 45

STATUS=`( (print ${database_password} | ${database_home}/bin/sqlplus "${database_username}"@"${database_connection_string}" @"fubar.sql" 4>&- 2>&1; echo $? >&4) | tee execute_61884_790746_5331464_Update_Tax_income_table_for_2013.log 1>&2 4>&-) 4>&1`
if [ "$?" -ne 0 ]
 then
   exit 44
fi
if [ -z "$STATUS" ]
then
  exit 45
fi
exit $STATUS

This works fine in ksh88 as well as in ksh93u and ksh93u+. Here is the correct output from ksh93u:

SQL> SET ECHO OFF;
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters and Automatic Storage Management options
+ echo 0
+ 1>& 4
+ STATUS=0
+ [ 0 -ne 0 ]
+ [ -z 0 ]
+ exit 0

Environment

  • Red Hat Enterprise Linux 6.3
  • ksh-20100621-19.el6.0.bz913110.x86_64
  • SQL database. In this case Oracle Database 11g

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content