chuckd has asked for the wisdom of the Perl Monks concerning the following question:

hi,
I'm calling sqlldr in a open statement like this:
open ($sqlldr3, "|sqlldr usr/pass\@db control=dc.ctl log=\"$ARGS[1]/dc +.log\" bad=\"$ARGS[1]/dc.bad\" direct=true") || rollback("Cannot open + sqlldr for dc\n");
and when it is called it outputs some info to the screen.
does anyone know how I can supress this output? I don't want to see it.
the output looks like this:
SQL*Loader: Release 10.1.0.2.0 - Production on Fri Dec 12 10:03:43 200 +8 Copyright (c) 1982, 2004, Oracle. All rights reserved.

Replies are listed 'Best First'.
Re: how to supress stdout
by kennethk (Abbot) on Dec 12, 2008 at 18:34 UTC

    <code> tags are your friend.

    You can get rid of output by overriding the default STDOUT.

    open(STDOUT, ">redirect.txt") or die "Problem redirecting STDOUT.";

    or make it go away entirely on UNIX-like systems as

    open(STDOUT, ">/dev/null") or die "Problem redirecting STDOUT.";

    Update:

    I should also point out you should make a backup of STDOUT before you redirect, so you can print to it later if you want...

    open(STDOUTBACKUP, ">&STDOUT");

      Also you can redirect only output of sqlldr:
      open ($sqlldr3, "|sqlldr usr/pass\@db >/dev/null 2>&1")
        hi
        what does this mean?
        >/dev/null 2>&1 in the open call? I see two redirects. Can you explain this?