Here's a real weird one. I can successfully invoke SQL*Plus (Oracle's SQL shell) from a Perl script. However, if I create a DBI connection first, it fails. The SQL script, test.sql:
select sysdate from dual; exit
and the perl script:
#!/usr/local/bin/perl use DBI; my $dbh = DBI->connect('DBI:Oracle:', 'scott', 'tiger', {RaiseError => + 1}) || die DBI::errstr; my @cmd = ( 'sqlplus', '-s', 'SCOTT/tiger', '@test.sql' ); my $output = qx{@cmd}; my $retcode = $?; if ($? == -1) { die "Error: $?: $!"; } print $output;
which dies with:
Error: -1: No child processes at ./test.pl line 17.

However if I comment line 4, it works! Now it works for me on an older system. The differences are:

older system: Perl 5.10.0, DBI 1.609,DBD::Oracle.1.23, Centos 5.4, Oracle 11g release 1

new system: Perl 5.10.1, DBI 1.609, DBD::Oracle.1.23, Centos 5.4, Oracle 11g release 2

To try and eliminate Perl, I used the vendor version (5.8) on the new system. The only thing I can guess is that the version of Oracle makes a difference. But before I go to all of the trouble of reinstalling Oracle, I'm wondering if anyone can offer a reason for my problem, and a solution.

Note: the actual code in my app uses IPC::Cmd to handle the external command call (and deal with stderr and stdout, etc). I simply use qx{} the test case above to illustrate the unerlying problem. In the real code, the SQL script runs without error, but the return status is always -1


In reply to Host command fails if there is a database connection by astroboy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.