newbie pipe question

Tal Einat tal.no.no.spam at gmail.com
Tue Sep 5 05:04:46 EDT 2006


linuxnooby at yahoo.com.au wrote:
> Hi
>
> I want to write a python script that accepts input ( a single line of
> text) from another program (squid proxy) and sends back output ( a
> single line of text). I am not sure how to go about this
>
> cheers David

If you want the script to recieve this line in stdin and write the
output to stdout, you can use the sys.stdin and sys.stdout file
objects. You can also just use "print ..." to write to stdout.
Something like this is simple and readable:

input_line = sys.stdin.readline()
<processing...>
print output_line

- Tal




More information about the Python-list mailing list