All,
I need to get the return value from a sql script and redirect the outputto a file.
One of the requirements is to avoid showing passwords to 'ps' and the same code needs to run on win and unix.
I am now calling the script using code as below.
--------- Start My Code open SQLP, "|sqlplus -s /nolog >> $output_file_name " or die "cannot open sqlplus $E +RRNO \n"; # Connect and execute the script. This is done by writing to the strea +m we open for sqlplus. SQLP "connect $user_name/$password \n" or die "cannot write in doScrip +t"; print SQLP "\@$script_name; \n" or die "cannot write in doScript"; close SQLP or die "cannot close in doScript"; print "Status is :" . ($? >> 8); --------- End My Code
The sql script I execute is :-
****** Start t.sql select sysdate from dual / exit 77 ****** End t.sql
This works if the exit value is 0 but anything else fails.
................. Start Error I see Uncaught exception from user code: cannot close in doScript at sqlutils.pm line 160. sqlutils::doSqlScript ('t.sql', 'scott', 'tiger@iasdb.local', 'a.log') called at tutils.pl ine 21 ................. End Error I see
Your suggestions please.
Thanks & Regards,
Sunil.

In reply to read return value from a sql script using piped open by Anonymous Monk

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.