Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > pipe command to script

Reply
Thread Tools

pipe command to script

 
 
Josh Close
Guest
Posts: n/a
 
      09-20-2004
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
 
Reply With Quote
 
 
 
 
Robert Kern
Guest
Posts: n/a
 
      09-20-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
http://www.velocityreviews.com/forums/(E-Mail Removed)

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
 
Reply With Quote
 
 
 
 
Josh Close
Guest
Posts: n/a
 
      09-20-2004
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


On Mon, 20 Sep 2004 12:24:25 -0700, Robert Kern <(E-Mail Removed)> wrote:
>
>
> 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
> (E-Mail Removed)
>
> "In the fields of hell where the grass grows high
> Are the graves of dreams allowed to die."
> -- Richard Harter
> --
> http://mail.python.org/mailman/listinfo/python-list
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open a command pipe for reading Rodrick Brown Python 2 08-23-2010 08:15 AM
Getting pipe output before command returns jvivenot Ruby 3 05-24-2006 05:18 PM
Problem: Windows Command line Pipe to stdin GerShar Python 1 10-31-2005 02:24 AM
[named pipe] i wanna know about validate of pipe handle of client lee, wonsun C++ 1 11-02-2004 04:29 AM
Why does IO::Pipe::END generate an EXCEPT pipe message? lvirden@gmail.com Perl Misc 1 06-02-2004 02:17 PM



Advertisments