|>
|> Hi. I'm trying to write a perl script, and learning perl as I go.
|> I'm trying to read the STDERR output from a command, and perform some
|> actions depending on what the output is.
|> In this case, I'm calling 'identify' from the Image Magick package, which prints
|> the image information to STDERR (size, type, etc).
|> I'm opening a pipe to read the info, but can't seem to read any STDERR data out. It looks like
|> pipes can only handle STDOUT, not STDERR.
|>
|> e.g
|> open (PIPE, "identify image | ") || die ...
|> while (<PIPE>)
|> extract the correct fields.
|>
|> close(<PIPE>);
|>
|> This will read the STDOUT, but I can't seem to make it read STDERR (either both
|> STDERR and STDOUT, or just STDERR). This is no STDOUT produced at all, so
|> the while (<PIPE>) loop simpyl drops out, and the STDERR gets printed to the screen.
|> Using
|> open (PIPE, "identify image |& ") || die
|> causes open to fail.
|>
|> Ant hints/tips/suggestions will be greatly appreaciated.
|>
|> I'd prefer an email reply, and a posted one will do.
|> Thanks,
|>
|>
|> Ash.
|>
|>
|>
|> --
|> CSIRO Div of Manufacturing Tech, Phone: +61 3 662 7799
|> Locked Bag No. 9, Fax: +61 3 662 7851
|> Preston, Vic, 3072, Australia.
That'll teach me to look at the FAQ!!!
I've found the answer.
Simply do :-
open (PIPE, "identify image 2>&1 | " ) || die ...
Just one of the sh incantations I didn't try...
Ciao for now.
Ash.
--
CSIRO Div of Manufacturing Tech, Phone: +61 3 662 7799
Locked Bag No. 9, Fax: +61 3 662 7851
Preston, Vic, 3072, Australia.