using python on the command line with 'here-documents' and pipes

Jeremy Bowers jerf at jerf.org
Mon Nov 15 00:38:53 CET 2004


On Sun, 14 Nov 2004 18:12:42 +0100, calmar wrote:
> It would be possible to use here-documents (for having the correct
> identation during e.g while loops) for writing python code on the fly, but
> then how and where to get the pipe output:
> 
> echo -e 'line1\nline2' | python <<EOF  ....
> 
> Does not really work...
> 
> Would anybody have an idea how to use python like e.g. awk etc. As a tool
> within, where I can handle the stdin data, and write the code right there
> (e.g. with here documents)?

Can you post a working example for awk? I'll admit I'm not a shell expert,
but it seems like you are trying to stuff two files onto stdin, the "echo"
result and the python program. I don't understand how that could ever
work, and now you've piqued my curiosity.




More information about the Python-list mailing list