I want to make sure that I can catch and report any errors I get from a CLT when called from a Perl script. I'm running TeamSite 5.0 on Windows 2000.
I will use iwgen as an example. If I try and run the following command (with intentional bad arguments) from the DOS prompt I know I will get an error from the iwgen program.
c:\iw-home\bin\iwgen -t jkjd -r jksd jljf.html
Returns:
jkjd: not a TeamSite Templating presentation template
If I try and do this from a Perl Script I want to be able to catch that error string. I've tried doing this using the $?, $!, $^E, and $@ sepecial variables but with no luck.
Here's a test Perl script
$cmd = "C:\\iw-home\\bin\\iwgen -t jkjd -r jksd jljf.html";
$result = `$cmd`;
print "\$result = $result\n";
print "\$? = $?\n";
print "\$! = $!\n";
print "\$^E = $^E\n";
print "\$\@ = $
@\n";
When I run this I get the following:
$result =
$? = 0
$! =
$^E = The pipe has been ended
$@ =
I know that because $? = 0 that the CLT failed but I don't know exactly why. Where is the error string
"jkjd: not a TeamSite Templating presentation template" ?
How can I trap that in my perl script?