in reply to Re^5: How to stop printing the output of a command on screen when the command fails?
in thread How to stop printing the output of a command on screen when the command fails?

I really need help on this.Tried in a different way as below,am not able to store the STDERR output into any variable.The below program doesnt print anything.I have been working on this since last night,couldnt get a handle on this.Any help is truly appreciated.

#!/usr/bin/perl -w use strict; use warnings; use diagnostics; #use diagnostics; use IPC::Open3; my @changed_paths; my @changed_files=("//depot/perl/tools/scripts/files/data.c"); foreach my $file (@changed_files) { my($wtr, $rdr, $err); use Symbol 'gensym'; $err = gensym; my $pid = open3($wtr, $rdr, $err,'p4 where $file'); print "$err\n"; #prints as GLOB(0x183f108),why is it so? #waitpid( $pid, 0 ); //Why do we need this?Program never halts if th +is is present my $child_exit_status = $? >> 8; if ($err eq 'file(s) not in client view') { push @changed_paths,$file; } print @changed_paths; }
  • Comment on Re^6: How to stop printing the output of a command on screen when the command fails?
  • Download Code

Replies are listed 'Best First'.
Re^7: How to stop printing the output of a command on screen when the command fails?
by RedElk (Hermit) on Dec 24, 2010 at 22:55 UTC

    The single quotes in line 13 of your posted code. Is that really what you want - not interpolated? Perldoc shows it differently.

Re^7: How to stop printing the output of a command on screen when the command fails?
by ikegami (Patriarch) on Dec 24, 2010 at 22:38 UTC

      What's confusing me is,if I run the below command from command prompt I see stderr getting supressed but where as when I run it in perl using backticks it fails,what could be going wrong>

      >p4 where //depot/perl/tools/files/data.c > NUL: 2>&1

        Please provide the output of the following:

        p4 where //depot/perl/tools/files/data.c > NUL: 2>&1 perl -e'system "p4 where //depot/perl/tools/files/data.c > NUL: 2>&1"' perl -e'`p4 where //depot/perl/tools/files/data.c 2>&1`'