pipe command to script
Robert Kern
rkern at ucsd.edu
Mon Sep 20 15:24:25 EDT 2004
Josh Close wrote:
> How can I read input from stdin pipe from somewhere?
>
> ex:
> # echo hello | script.py
>
> I was thinking opening file() or popen() with sys.stdin, but that
> didn't work. I've done this before but don't have the code anymore and
> can't figure it out again.
sys.stdin is already an open file object. Just call sys.stdin.read().
> Thanks.
>
> -Josh
--
Robert Kern
rkern at ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
More information about the Python-list
mailing list