[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: non-blocking stdin from bash



On Sun, 2018-08-12 at 19:47 +0200, tomas@tuxteam.de wrote:
> On Sun, Aug 12, 2018 at 12:34:08PM -0400, Jim Popovitch wrote:
> 
> [...]
> 
> > Turns out I had mis-read your first reply as "-t 1", chiefly
> > because
> 
> Ah, I see.
> 
> > that was all that I had found before posting here.  What now works
> > for
> > me avoids the -t param:
> > 
> > 
> > while read stdin_line
> > do
> >    MSG=$MSG"\n"$stdin_line
> > done < /dev/stdin
> 
> This will block in the read as long as the line isn't yet terminated.
> But of course fine, if it rocks your boat :-)

Interesting.  I'm using it via a cron script like so:

* * * * *  grep "unusual" /opt/logs/* | /opt/notify.sh `hostname`;

so it should always be terminated.

-Jim P.




Reply to: