Question : Perl - capture error from output

I have a script as below, the script will checkout a list of files from CVS, that all works fine, the problem I have is on the error checking I want to put in, when running the script (on a solaris box) I get output as show below, in this example for checkout number 3 I get a error "cannot find - ignored".

How can I capture the output so I can print out a warning of my own and not include the one ignored in my count, so for this example I have 19 files to be check out, so I want to do a check at the end and if count does not = 19 I can print out a message, the part I cannot get is how to capture the line of file ignored from the Standard Output.


script OUTPUT:

===================================================================
Checking out development/directory-interface/help/alias.html
RCS:  /DATA/cvs/development/directory-interface/help/alias.html,v
VERS: 1.5
***************
count is: 1
===================================================================
Checking out development/directory-interface/help/building-records.html
RCS:  /DATA/cvs/development/directory-interface/help/building-records.html,v
VERS: 1.5
***************
count is: 2
cvs checkout: cannot find module `development/directory-interface/help/FAQ.html' - ignored
count is: 3
===================================================================
Checking out development/directory-interface/help/faq-details.html
RCS:  /DATA/cvs/development/directory-interface/help/faq-details.html,v
VERS: 1.9
***************
count is: 4
==================================================================

.......

===================================================================
Checking out development/directory-interface/index.html
RCS:  /DATA/cvs/development/directory-interface/index.html,v
VERS: 1.27
***************
count is: 19
files checked out is: 19


------------------------------------------------



Thanks,
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
#! /usr/bin/perl
use: strict;
use File::Basename;

my @CVSfiles = qw(
development/directory-interface/help/alias.html
development/directory-interface/help/building-records.html
development/directory-interface/help/FAQ.html
development/directory-interface/help/faq-details.html
development/directory-interface/help/faq-manager-promotion-dn-changes.html
development/directory-interface/help/faq-moc.html
development/directory-interface/help/LDAP_to_AD_FAQs.html
development/directory-interface/help/password.html
development/directory-interface/help/images/LDAP_to_AD.gif
development/directory-interface/help/images/gal-01.gif
development/directory-interface/help/images/gal-02.gif
development/directory-interface/help/images/gal-03.gif
development/directory-interface/help/images/gal-04.gif
development/directory-interface/help/images/gal-05.gif
development/directory-interface/help/images/gal-06.gif
development/directory-interface/help/images/gal-07.gif
development/directory-interface/help/images/gal-08.gif
development/directory-interface/query.html
development/directory-interface/index.html
);

my $count = 0;

while  (<@CVSfiles>) {
 if (/^development/) {
   chomp;
   $path=$_;
   $file=basename $_;
   system("cvs checkout -p $path > $file\n");

$count ++;
print qq{count is: $count\n};

 }
}

print qq{files checked out is: $count\n};

Answer : Perl - capture error from output

Actually, on the print on line 39, it should probably just be

print @err if @err;

since I never stripped the newlines from the output (to do that you can just add to line 37 "my @err = map { chomp; $_ } grep ...").
Random Solutions  
 
programming4us programming4us