[Tutor] parsing sendmail logs

Alan Gauld alan.gauld at btinternet.com
Tue Jul 15 09:47:13 CEST 2008


"Monika Jisswel" <monjissvel at googlemail.com> wrote

> but if you want to go on your own I believe awk, grep, sort  are 
> extremely
> extremely  extremely (yes 3 times !) powerfulI tools, so giving them 
> up is a
> ...
> a python program that uses them thru subprocess module,

I am a big fan of awk but I'd never write a Python script
to call an awk script vias subprocess unless the awk script already
existed and was very big. There is nothing that awk can do that
Python cannot and the amount of code is about the same in each case.
And the overhead of starting a new awk process from subprocess
is quite high and then you have the additional overhead of getting
the input/output data transferred. It is all a very cumbersome process
that is not justified IMHO unless the awk code already exists
and is too big to rewrite. (The same applies to sort/grep if the 
Python
script has to use the data otherwise sort is a valid option).

Does that mean you can't combine awk/python - no. If you are
not using the awk data in the python script then run awk separately
to Python but in that case use bash or ksh to coordinate not Python.
But I struggle to think of a good case for using awk via subprocess
(or os.system/popen etc).

Alan G. 




More information about the Tutor mailing list