[pca] PCA return codes

Ray Van Dolson rvandolson at esri.com
Wed Sep 24 19:46:44 CEST 2008


On Wed, Sep 24, 2008 at 01:06:14AM -0700, Martin Paul wrote:
> Christophe Kalt wrote:
> > On Sep 16, Fred Chagnon wrote:
> > | In my wrapper script for pca, I would like to be able to determine if pca
> > | finished patching completely, or if it finished prematurely, perhaps due to
> > | a patch that required an immediate reconfigure reboot. Does pca have
> > | different return codes for these situations?
> >
> > Agreed, suggested it back in February as it's part of what
> > makes it painful to write a decent wrapper around pca.
> 
> I know, but I still haven't found a solution for the problem that there
> are multiple different situations which should be reported by pca, all
> in one exit value.
> 
> For the wrapper script it might be interesting whether pca installed
> some patch and succeeded or failed (with all or just one of many). Was
> there a download attempt that failed? If patches were installed - is a
> reboot recommended or required? What if one patch fails to download,
> another downloads fine but fails to install, and even another downloads
> and installs fine?
> 
> I guess a solution might be to use different bits in the exit value for
> various cases, e.g.:
> 
>    bit 0: set if a download was successful
>    bit 1: set if a download failed
>    bit 2: set if any patch was installed successfully
>    bit 3: set if any patch failed to install
>    bit 4: reboot recommended
>    bit 5: reboot required
>    bit 6: set if any patch is listed, 0 if none
>    bit 7: general error (external command not found, etc.)
> 
> There are two problems with that as well: Even with the above examples,
> all 8 bits are already used - there's no space for extra flags in the
> future (and I'm sure some of you can think of other required flags right
> now).

Perhaps assume the above is a well defined baseline of errors, but
reserve one (bit 7?) for anything not handled.  In cases where people
are trying to write wrappers around pca, pca could be passed a flag to
write extended error codes somewhere else -- a file or pipe which could
then be processed by the wrapper.  If bit 7 is set, the wrapper would
know to check the alternate location for additional information.

Maybe too complex. :)

> Plus, not every shell does have bitwise logical operators; at least I
> couldn't find a way to handle such an exit code in e.g. bourne shell
> (and the "test" and "expr" commands don't seem to handle it either).
> 
> Ideas, anyone?

You can do bitwise with regular 'ol bourne shell in tandem with bc and
sed.  It's not pretty but doable. :-)

I guess if anything more complex needed to be done bash, csh, perl,
python could be the recommended method.

Ray



More information about the pca mailing list