
Jeff29
Novice
Dec 24, 2010, 9:24 AM
Post #3 of 6
(800 views)
|
|
Re: [FishMonger] 2>&1 not working in backticks
[In reply to]
|
Can't Post
|
|
I did try the open3 way but I am getting the following error.I have been trying various ways but couldnt get anything working.Any help is truly appreciated Can't locate object method "p4" via package "where" (perhaps you forgot to load "where"?) at stderr.pl line 25 (#1) (F) You said to do (or require, or use) a file that couldn't be found. Perl looks for the file in all the locations mentioned in @INC, unless the file name included the full path to the file. Perhaps you need to set the PERL5LIB or PERL5OPT environment variable to say where the extra library is, or maybe the script needs to add the library name to @INC. Or maybe you just misspelled the name of the file. See perlfunc/require and lib. Uncaught exception from user code: Can't locate object method "p4" via package "where" (perhaps you forgot to load "where"?) at stderr.pl line 25.
#!/usr/bin/perl -w use strict; use warnings; use diagnostics; use Data::Dumper; use Storable; use Getopt::Std; use File::Glob (); use Cwd; #use diagnostics; use IPC::Open3; my @changed_paths; my @changed_files=("//perl/tools/files/data.c"); foreach my $file (@changed_files) { $file =~ s/#\d+$//; print "FILE:$file\n"; #my $p4where_output=`p4 where $file > NUL: 2>&1`; #print "P4 where output:$p4where_output\n"; my $cmd = "p4 where $file"; local(*HIS_IN, *HIS_OUT, *HIS_ERR); my $childpid = open3(*HIS_IN, *HIS_OUT, *HIS_ERR, p4 where $cmd); print HIS_IN "stuff\n"; close(HIS_IN); # Give end of file to kid. my @outlines = <HIS_OUT>; # Read till EOF. my @errlines = <HIS_ERR>; # XXX: block potential if massive print "STDOUT:\n", @outlines, "\n"; print "STDERR:\n", @errlines, "\n"; print @errlines; close HIS_OUT; close HIS_ERR; waitpid($childpid, 0); if ($?) { print "That child exited with wait status of $?\n"; } if(@errlines eq 'file(s) not in client view') { push @changed_paths,"$file\n"; } print @changed_paths; }
|