Re: Testing for the presence of input from stdin.

2006-01-24 Thread Thomas Bellman
Peter Gsellmann <[EMAIL PROTECTED]> writes: > Will McDonald wrote: >> That's a good point. I did wonder if it'd just have to sit there >> waiting for input much like cat would. I think that's preferable, and >> simpler :), than implementing timeouts. >> > In unix you can always use select.select

Re: Testing for the presence of input from stdin.

2006-01-24 Thread Fredrik Lundh
Will McDonald wrote: > > There are more experienced UNIXers here, but from my POV I don't see how > > that can happen. The reason is simply that > > > > - sys.stdin alwasy exists (unless you close it yourself) > > > > - in a pipe (which this essentially is) there is now way to know if there > >

Re: Testing for the presence of input from stdin.

2006-01-24 Thread Will McDonald
On 24/01/06, Roland Heiber <[EMAIL PROTECTED]> wrote: > Will McDonald wrote: > > Hi all. > > > > I'm writing a little script that operates on either stdin or a file > > specified on the command line when run. I'm trying to handle the > > situation where the script's run without any input gracefully

Re: Testing for the presence of input from stdin.

2006-01-24 Thread Roland Heiber
Will McDonald wrote: > Hi all. > > I'm writing a little script that operates on either stdin or a file > specified on the command line when run. I'm trying to handle the > situation where the script's run without any input gracefully but > can't think how to test for stdin. > Hi, maybe http://d

Re: Testing for the presence of input from stdin.

2006-01-23 Thread Peter Gsellmann
Will McDonald wrote: > On 23/01/06, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >> > I can get the script to behave as expected when content's piped to it >> > using sys.stdin but I'd like to know that there's data coming from >> > stdin or fail and print the useage again. Is there a simple way to

Re: Testing for the presence of input from stdin.

2006-01-23 Thread Will McDonald
On 23/01/06, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > > I can get the script to behave as expected when content's piped to it > > using sys.stdin but I'd like to know that there's data coming from > > stdin or fail and print the useage again. Is there a simple way to > > achieve this? > > Ther

Re: Testing for the presence of input from stdin.

2006-01-23 Thread Diez B. Roggisch
> I can get the script to behave as expected when content's piped to it > using sys.stdin but I'd like to know that there's data coming from > stdin or fail and print the useage again. Is there a simple way to > achieve this? There are more experienced UNIXers here, but from my POV I don't see how