Problem with sys.exit()

Steven M. Castellotti scastell at sas.upenn.edu
Fri Jun 30 12:07:22 EDT 2000


Greets all,

	I'm having some difficulty with a particular python script. I'm taking
gzipped log files and calling zcat (from the command line) with one
script (feeder.py), which pipes the output to the second script
(parser.py). The second script addes up few things, and I want it to
report the final total back to the feeder script. I tried passing it via
sys.exit() (ugly I know, but it seemed like a good idea at the time) but
when I use the numbers in the feeder script, the numbers are way off:

End of parser.py:

print total_registrations
sys.exit(total_registrations)

Relevant portion of feeder.py:

...

grand_total = grand_total + \
  os.system('zcat %s | python authlog_parser.py' % (filename) )
print "%i" % os.system('zcat %s | python authlog_parser.py' % (filename)
)
print "Grand Total: %s" % grand_total


But my output looks something like this:

3
768
Grand Total: 1024

	...where the "3" is the actual total getting passed into sys.exit(),
768 is what parser.py is recieving, and 1024 being the total.

	Any ideas about what might be wrong, or perhaps a better way to do
this? If there was a way to read a gzip'd text file directly into python
that'd probably take care of it, but why isn't this working?

-- 
Steve Castellotti
Systems Programmer
School of Arts and Sciences, University of Pennsylvania



More information about the Python-list mailing list