The community will be in read-only from Monday 11:59pm (PT) to Wednesday 7:30am (PT)
The community will be in read-only from Monday 11:59pm (PT) to Wednesday 7:30am (PT)
Project and Portfolio Management Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Continue Execution Even when Exit Status isn't 0

Highlighted
Tommy Honahan
Super Collector

Continue Execution Even when Exit Status isn't 0

Hi All,

How would I go about making my object types continue executing continuing to execute even if one of the commands I execute does not have an exist status of 0?

For example, let's say my object calls a script on a UNIX server. The script returns 3 values: 0, 1, and 2

Currently if I execute the script, and it returns a value of 1, PPM will read this as an error and fail the object. Is there something I can wrap around the command to tell PPM to keep going even if the status isn't 0?
3 REPLIES
Jason Nichols K
Honored Contributor

Re: Continue Execution Even when Exit Status isn't 0

Tommy,

I had a similar problem many years ago with an application that intentionally returned non-zero successful return codes. What I did was wrap the execution in a one line perl script:

perl -e 'eval {$result=``; #test result here to make sure you got what you expected and set $retVal; } return $retVal;'

This just went in the command set while connected to the server. I'm sure there are other ways of doing what you need, but this trick worked for me.
Jim Esler
Honored Contributor

Re: Continue Execution Even when Exit Status isn't 0

You can capture the command's return code and modify the processing in several different ways. The key is that PPM will only see the return code from the last command in the string. Some of the things we do are:

command;RESULT=$?


command;if [ $? > 3 ];then false;else true;fi
Tommy Honahan
Super Collector

Re: Continue Execution Even when Exit Status isn't 0

Ahhh. Thanks guys.
//Add this to "OnDomLoad" event