Why not using the program output as a 'logical return value' ?
(will show you if the program 'worked' and not only if the program excuted correctly...)
For example :
Modify your prog to display 'ok' at the end, if everything is ok.
In the case of a program that you can't modify,
a regex matching a typical message for success/correct behaviour will be used.
(obiously no/truncated/incorrect output -> pb)
UPDATE : Thinking twice about it, it sounds a really weird way...
UPDATE2 (after stefan_k and davorg answers): Now that it's clear that it's not the usual (correct?) way to do it
(use of $? is the right answer) could someone spot a flaw/weakness/drawback in my idea ?
And tell me why it's not used more often...
"
Only
Bad
Coders
Badly
Code
In
Perl" (OBC2IP)