On Feb 1, 2008 9:26 AM, <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> 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.
>
> Can I do that????
snip
This depends heavily on the shell you are using. Under most (if not
all) Unix shells you can say
my $output = qx{/usr/atria/bin/cleartool lslock lbtype:$dep_lbl 2>/dev/null};
to redirect the file handle 2 (STDERR) to the bit bucket (/dev/null).
A better solution is not to use the qx// operator. The IPC::Open3*
module lets you run a command with complete control over its STDIN,
STDOUT, and STDERR.
* http://perldoc.perl.org/IPC/Open3.html
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/