sdyates has asked for the wisdom of the Perl Monks concerning the following question:
I am once again having a devil of a time. This time standard error is not working for me as it should!
In my code below, I want to run a command that test an image file. If the identify command creates an error, it should write the file name to error.txt. All other info should go to dump.txt.
dump.txt works well and captures all but the error info. However, error.txt captures all file names.
. . . RetrieveValues(); CheckImageArchieve(); sub RetrieveValues { print "\n\nSpecify the Directory path to image folder:\n"; $directory = (<STDIN>); chomp $directory; # $directory =~ s/\\/\\\\/g; } sub CheckImageArchieve { my $a = 0; opendir(DIR, $directory) or die "Cannot open directory $directory" +; my @DIR = grep {$_ ne '.' && $_ ne '..' && grep (m/fpx/, $_)} read +dir DIR; system ("cls"); while ($DIR[$a]) { print "$directory\\$DIR[$a]\n"; system("echo $directory\\$DIR[$a] >> c:\\dump.txt"); system("identify -verbose $directory\\$DIR[$a] >> c:\\dump.txt"); or system("echo ERROR: $directory\\$DIR[$a] >> c:\\error.txt") +; $a=$a+1; } }
In the past, when I have had trouble with opening files, I would use the same redirection and it would work. I difficulty arises here because i am using a command line utility. Is my code proper, or is the command causing the issue?
Please advise,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Redirecting errors
by grep (Monsignor) on May 09, 2002 at 20:52 UTC | |
|
Re: Redirecting errors
by graff (Chancellor) on May 09, 2002 at 21:15 UTC | |
|
Re: Redirecting errors
by PrimeLord (Pilgrim) on May 09, 2002 at 20:51 UTC | |
by sdyates (Scribe) on May 09, 2002 at 21:36 UTC | |
by Rex(Wrecks) (Curate) on May 09, 2002 at 22:28 UTC | |
|
Re: Redirecting errors
by cmilfo (Hermit) on May 10, 2002 at 05:50 UTC |