pipe command to script

J

Josh Close

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.

Thanks.

-Josh
 
R

Robert Kern

Josh said:
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
(e-mail address removed)

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
 
J

Josh Close

Nice, that's easy. I did it some other way last time that worked
also..... probably doing things twice the other way though.

Thanks!

-Josh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,829
Latest member
PIXThurman

Latest Threads

Top