please help me understand os.system() result

Keisuke URAGO bravo at resourcez.org
Tue May 20 08:39:38 EDT 2003


Hi, Roman.

On Tue, 20 May 2003 15:17:17 +0400 (MSD)
Roman Suzi <rnd at onego.ru> wrote:

> 
> Under Linux I have very strange results for exit status info:
> 
> >>> os.system("exit 7")
> 1792
> >>> os.system("python -c 'import sys;sys.exit(1)'")
> 256
> >>> os.system("python -c 'import sys;sys.exit(2)'")
> 512
> 
> True for my RH 7.3 and 6.2, for Pythons 1.5.2, 2.1, 2.2.2.
> 
> Any ideas?

You should shift 8bits like this.

>>> os.system("exit 7") >> 8
7
>>> os.system("python -c 'import sys;sys.exit(1)'") >> 8
1
>>> os.system("python -c 'import sys;sys.exit(2)'") >> 8
2

Cheers,

==
Keisuke URAGO <bravoNOSP at Mresourcez.org> http://open.resourcez.org/
Key fingerprint = B64B 4D6B 45A7 74FB 5537  A57A 6027 F69D 0188 3935




More information about the Python-list mailing list