Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pipiing doesn't work!

Status
Not open for further replies.

drkestrel

MIS
Sep 25, 2000
439
GB
I have two piping block of codes, one is piping output from Oracle SQL Plus, and one from Oracle Exporting (exp command). The Exp doesn't work, though same syntax!
Anyone see anything wrong??-
Code:
$expCmd = "exp userID=dba/sql file=" . $exportFile . " compress=N |";
open (EXP,$expCmd) 
            or logError ("Attempted to run ".$expCmd . "-Failed: $!\n");
while (<EXP>)
{
    $outputStr .= $_;
    logDebug(&quot;-&quot;.$outputStr);
}
close EXP;


logDebug(&quot;-&quot;.$outputStr)
didn't get executed at all!

and output is dump to terminal!! Wassup?? I do have the | here!
 
an idea, not a solution:
it may be that the oracle thingy is printing to STDERR... there's an entry in the perlfaqs about capturing the STDERR of a pipe, if this is the case. &quot;If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito.&quot;
 
Try

$expCmd = &quot;exp userID=dba/sql file=&quot; . $exportFile . &quot; compress=N 2>&1 |&quot;;
Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Well, I guess (from looking at perlfaq8) that
Code:
$expCmd = &quot;exp userID=dba/sql file=&quot; . $exportFile . 
&quot; Compress=N 2>&1

should captures STDOUT and STDERR.

The have got an literally identical commands for Oracle Import.

I run my script like the following-
Code:
nohup perl myScript.pl config.cfg &

When things go correctly (i.e., when output goes to STDOUT), I did manage to get the PIPE OK, but when import fails (when things get to STDERR), then Perl can't pick up the pipe!, and errors goes to nohup.out!

Can I stop Oracle/Perl from outputting to nohup.out (or the terminal) and let it be piped to my script instead?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top