On Feb 1, 2008 6:26 AM,  <[EMAIL PROTECTED]> wrote:

> I want to hide the standard output on the terminal when I am executing
> the Perl script. For example I am running this command
> "`/usr/atria/bin/cleartool lslock lbtype:$dep_lbl`;
>
> if the execution of this command failed then whatever output is coming
> on the terminal I want to hide that and I want to print my standard
> statement.

Do you want to run your command in backticks, so as to capture (and
thereby suppress) its STDOUT? You may wish to redirect STDERR as well.
This example uses shell redirection syntax to send the command's
STDERR to the same place as STDOUT was going, which is to say, back to
perl:

  my $result = `$command 2>&1`;  # capture all output
  if ($?) {
    print "Standard command failure statement.\n";
  }

Backticks are the simple form of the qx// operator, documented in the
perlop manpage.

    http://perldoc.perl.org/perlop.html#Quote-Like-Operators

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to