[OT] Re: return level?

David Relson relson at osagesoftware.com
Tue Feb 18 18:09:48 CET 2003


At 12:01 PM 2/18/03, Matej Cepl wrote:

>David Relson wrote:
> > Then run the scripts from your python program and see what it prints.
> >
> > Also, run bogofilter from the command line and use "echo $?" to see what
> > it's really returning.
>
>This is really weird:
>
>    ~% echo exit 0 > zero
>    ~% echo exit 1 > one
>    ~% echo exit 2 > two
>    ~% chmod +x zero one two
>    ~% ./zero ; echo $?
>    0
>    ~% ./one  ; echo $?
>    1
>    ~% ./two  ; echo $?
>    2
>    ~% python
>    Python 2.1.3 (#1, Sep  7 2002, 15:29:56)
>    [GCC 2.95.4 20011002 (Debian prerelease)] on linux2
>    Type "copyright", "credits" or "license" for more information.
>    >>> import os
>    >>> os.system("/home/matej/one")
>    256
>    >>> os.system("/home/matej/two")
>    512
>    >>> os.system("/home/matej/zero")
>    0
>    >>>
>    ~% bogofilter < relson
>    ~% echo $?
>    1
>    ~%
>
>(relson is obviously your previous mail). Does it mean, that
>I should divide returned value by 256 or that I should make some
>bitwise masking (xoring?)?
>
>    Thanks for help,
>
>       Matej

Mateej,

Looks like python is doing a "left shift 8" of the return code and you 
should do a "right shift 8" to get the value you want.  If I were you, I'd 
take a look at the documentation of os.system() and see what it's returning.

I don't think what you're seeing is really weird.  It _is_ unexpected and 
surprising.  I'm sure there's a good reason for it as well.  With luck, the 
documentation will explain it all.

David






More information about the Bogofilter mailing list