Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Not able to report the exceptions correctly
apsmiles
Hi,
I have written a script to generate and regenerate files. I have one directory (say htmls ) parallel to templatedata folder in a WORKAREA ( Devlp). I am generating all html files into the htmls directory. The only different thing is, I am doing all this in another workarea ( Prod ). I am copying (using iwupdate -x) from Dev to Prod workarea only the required dcrs. Then from a script i am generating html files in htmls of Prod workarea by providing absolute paths ( from /default/main/.../Prod/templatedata/cat/data/xyz.dcr etc). [Please refer to my post on 01/27/05 02:04 PM titled "
contents of child dcrs not coming up
".
I am using following function to execute all the commands:
sub executeCommand($) {
my $command = shift;
my $execRes;
my $output;
try
{
$logger->debug("Command Run : $command");
$output = qx($command 2>&1);
sleep(1);
$execRes = 1;
$logger->debug("Command res : $?");
}
otherwise
{
$execRes = 0;
$logger->error("\n Couldnot run command: $command");
};
return ($execRes, $output);
}
try and otherwise are methods of Error.pm(custom package) which is included on the top of the page and is used to catch perl exceptions only.
And this is how I am calling it when I need to generate a file:
$cmdRes = executeCommand($cmd);
if($cmdRes == 1)
do something
else
do some other thing
There was a generation, in which the html file couldnot be generated because there was not a configured file extension. Let me put the exact command I ran on console and the result:
Command :
/opt/teamsite/bin/iwgen -t /default/main/build/en/WORKAREA/Mulan/templatedata/custom_aisles/CAProgramDetails/presentation/CAProgramDetails.tpl -r /default/main/build/en/WORKAREA/Mulan/templatedata/custom_aisles/CAProgramDetails/data/ar/APDetails_anil.dcr /default/main/build/en/WORKAREA/Mulan/en/custom_aisles/ar/APDetails/APDetails_anil.html
/default/main/build/en/WORKAREA/Mulan/templatedata/custom_aisles/CAProgramDetails/presentation/CAProgramDetails.tpl: does not have a configured filename extension
The text in red is the error message I recieved when
I ran the command on console
. So, while the script called the same code through the function executeCommand(), the function should have returned 0 and not 1. But the logs show that the command ran successfully i.e. returned 1, but no html was generated.
Let me sum up again to avoid any confusion:
When the script returns successful execution, there should be a html generated and else not.
Can somebody guide me, how can I catch such situations and so
report correct status
. Or should I use some other error handling tool to catch the exceptions correctly.
Thanks in advance
Anil
Find more posts tagged with
Comments
Adam Stoller
I didn't see the debug log output in your post - specifically the lines that say:
Command Run: ...
Command res: ...
The last one is of most interest because the way your code is written - you're setting $execRes to 1 without having verified that the command was successful.
In order to fix the problem with the extension error - you can either use iwpt_compile.ipl instead of iwgen, or configure the PT in your templating.cfg file.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
apsmiles
Here are the outputs:
2005/01/31 07:44:26 [DEBUG] deploy.pl:769 main:lithium_ANON__ - Command Run : /opt/teamsite/bin/iwgen -t /default/main/build/en/WORKAREA/Mulan/templatedata/custom_aisles/CACallMeURLRaw/presentation/CACallMeURL.tpl -r /default/main/build/en/WORKAREA/Mulan/templatedata/custom_aisles/CACallMeURLRaw/data/corp/IBM_gov1.dcr /default/main/build/en/WORKAREA/Mulan/en/custom_aisles/corp/IBM/IBM_gov1.html
2005/01/31 07:44:27 [DEBUG] deploy.pl:773 main:lithium_ANON__ - Command res : 0
And yes, this is what I want to do: how should I catch the exceptions (related to IW), and report them accordingly. We'll definitely modify our tpls, but at the same time we need to report any exceptions, correctly.
Thanks
Anil
Adam Stoller
And if you run this same command from the command line - you're getting an error about the PT not being configured for an extension?
What shell are you using for the command line: csh/tcsh or sh/ksh/bash or ?
if using csh or tcsh do:
prompt> iwgen ....
prompt> echo $status
If using sh, ksh, or bash do:
prompt$ iwgen ...
prompt$ echo $?
If the command says that you didn't have the PT configured yet $status and/or $? return 0 -- then it just means that this is one of many cases where IWOV CLTs do not correctly return exit status values - and you should file a bug with Support. (I find this less likely with iwgen and iwpt_compile.ipl because Jon **** tended to be good about this kind of issue).
So again, it sounds like you're faced with either using iwpt_compile.ipl or fixing your templating.cfg file to configure the PT correctly.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com