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,In reply to Redirecting errors by sdyates
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |