Unix Technical Forum

How to know if read is pending on pipe

This is a discussion on How to know if read is pending on pipe within the AIX Operating System forums, part of the Unix Operating Systems category; --> Hi, I have shell scripts executing several programs. Both the script and the programs may use stdin and stdout ...


Go Back   Unix Technical Forum > Unix Operating Systems > AIX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-04-2008, 08:02 PM
Helmut Leininger
 
Posts: n/a
Default How to know if read is pending on pipe

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?


Regards
--
Helmut Leininger

Bull AG / Vienna
Open Systems Support

Email: h.leininger@bull.at

This opinion is mine and not necessarily that of my employer.
No guarantees whatsoever.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-04-2008, 08: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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:49 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com