return code and sqlplus

Calling a shell script from within sqlplus is buggy…

I have reported bug 3798918 in 10.1.0.2 (back in 2004) and bug 13349119 in 11.2.0.3 because some metalink guru closed 3798918 as not reproducible.

As written in return code, host does not return the correct code


SQL> host exit 7
SQL> def _RC
DEFINE _RC             = "0" (CHAR)

If you never use _RC, you may believe you are safe. But watch this :


SQL> get foo.sh list
  1  #!/bin/sh
  2  if /bin/false
  3  then
  4    echo this is wrong
  5* fi
SQL> host ./foo.sh
this is wrong

The return code not being set is not only affecting the _RC variable, but it is also affecting all subshells !

Note this is not reproducable with SQLPLUS /NOLOG


SQL> host false
SQL> def _rc
DEFINE _RC             = "1" (CHAR)
SQL> conn x/x
ERROR:
ORA-01017: invalid username/password; logon denied
SQL> host false
SQL> def _rc
DEFINE _RC             = "0" (CHAR)

After my (failed or successfull) tentative to connect as x/x, it is reproducible again

3 thoughts on “return code and sqlplus”

  1. I was a bit skeptical about the bug affecting subshells, so I tried it on AIX and I can’t get it to reproduce, either using ksh or bash.

    What platform are you on?

    Also, for 10.2.0.4 on AIX I get the _RC bug regardless of /nolog.

  2. ok, I am glad you are sceptical :)

    I can reproduce it with 10.2.0.4 on AIX 6 with /nolog and / as sysdba

    I can reproduce it with 11.2.0.3 on AIX 6 with / as sysdba

    I do not have bash installed.

  3. with nolog, aix 6.1 ML 6, oracle 10gR2

    
    sqlplus /nolog
    
    SQL*Plus: Release 10.2.0.4.0 - Production on Tue Dec 18 14:23:12 2012
    
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    
    SQL> ho /bin/false
    
    SQL> def _RC
    DEFINE _RC             = "0" (CHAR)
    SQL> ho oslevel -r
    6100-06
    

    with connection, same environment

    
    SQL> conn / as sysdba
    Connected.
    SQL> ho /bin/false || echo yes
    
    SQL>
    

    Any doubt ?

Leave a Reply

Your email address will not be published.


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>