get the return code when piping something to a python script?

mhenry1384 mhenry1384 at gmail.com
Tue Aug 16 13:55:16 EDT 2005


On WinXP, I am doing this

nant.exe | python MyFilter.py

This command always returns 0 (success) because MyFilter.py always
succeeds.

MyFilter.py looks like this

while 1:
    line = sys.stdin.readline()
    if not line:
        break
    ...
    sys.stdout.write(line)
    sys.stdout.flush()

How do I set the return code from MyFilter.py based on the return of
nant.exe?  Is this possible?  I have googled around for an hour wihtout
success.  I understand that I could have MyFilter.py call "nant.exe",
but for various reasons, that's not idea for my situation.




More information about the Python-list mailing list