View Single Post

   
  #2 (permalink)  
Old 01-04-2008, 09:02 PM
Nenad
 
Posts: n/a
Default Re: How to know if read is pending on pipe

"Helmut Leininger" <h.leininger@bull.at> wrote in message
news:bjha6j$ieg4h$1@ID-54033.news.uni-berlin.de...
> Hi,
>
> I have shell scripts executing several programs. Both the script and the
> programs may use stdin and stdout to interface with the operator.
>
> Now, I want another program to get the script's stdout and eventually
> write to its stdin.
>
> Basically, this seems to be a case for using the pipe mechanism. The
> problem is, that I do not want to write into the script's stdin when
> there is no read pending. I cannot predict when and if the script wants
> an input, either.
>
> So, I need a possibility to test if if there is a read pending at the
> other end of the pipe before I write into it. Maybe it is a silly
> question, but how can I do this?
>

AFIK, there is no way to tell if there is a read pending at the other end of
the pipe.
For the case you described, I use GNU program called expect.

Nenad


Reply With Quote