<div dir="ltr">Aw. I was afraid of that. In my &#39;production&#39; script there would be a long time between most reads, so it&#39;s unlikely there would be a problem, but I still don&#39;t want rare random failures. I&#39;ll find a work-around.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Mar 1, 2014 at 2:12 PM, Adam Thompson <span dir="ltr">&lt;<a href="mailto:athompso@athompso.net" target="_blank">athompso@athompso.net</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">Oh, it&#39;s obvious when I think about it - the behavior of a pipe with multiple readers is well-defined as being OS and clib-dependent.<br>

Each byte is only available to one reader, ever - if the reading is interleaved, each reader will get garbage.<br>
You can use tee(1) to write to multiple FIFOs at once, or just adapt the writing script to do so manually.<br>
-Adam<br>
<br>
On Mar 1, 2014 1:35 PM, Kevin McGregor &lt;<a href="mailto:kevin.a.mcgregor@gmail.com">kevin.a.mcgregor@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; The writer is:<br>
&gt; #/bin/ksh<br>
&gt; PIPE=/tmp/backup.pipe<br>
&gt; [[ ! -a $PIPE ]] &amp;&amp; mkfifo $PIPE<br>
&gt; # Start gzip processes<br>
&gt; /opt/cronjobs/zip1 &amp;<br>
&gt; /opt/cronjobs/zip2 &amp;<br>
&gt;<br>
&gt; # Process files needing compression<br>
&gt; let &#39;fc=0&#39;<br>
&gt; ls /zonebackup/*tar | while read F; do<br>
&gt;         echo $F &gt;$PIPE<br>
&gt;         let &#39;fc=fc+1&#39;<br>
&gt; done<br>
&gt;<br>
&gt; echo &quot;end of list&quot; &gt;$PIPE<br>
&gt; echo &quot;end of list&quot; &gt;$PIPE<br>
&gt; exit 0<br>
&gt;<br>
&gt; The readers are:<br>
&gt; #/bin/ksh<br>
&gt; PIPE=/tmp/backup.pipe<br>
&gt; NAME=zip1<br>
&gt; if [[ ! -a $PIPE ]]; then<br>
&gt;         logger -p local0.warning &quot;$NAME can&#39;t find $PIPE -- exiting&quot;<br>
&gt;         exit 1<br>
&gt; fi<br>
&gt;<br>
&gt; while (( 1 )); do<br>
&gt;         read F &lt;$PIPE<br>
&gt;         if [[ &quot;$F&quot; = &quot;end of list&quot; ]]; then<br>
&gt;                 break<br>
&gt;         else<br>
&gt;                 echo &quot;$NAME: $F&quot;<br>
&gt;         fi<br>
&gt; done<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Sat, Mar 1, 2014 at 1:29 PM, Kevin McGregor &lt;<a href="mailto:kevin.a.mcgregor@gmail.com">kevin.a.mcgregor@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; I tried fiddling with IFS to no avail. I just changed it like this:<br>
&gt;&gt; IFS=&#39;<br>
&gt;&gt; &#39;<br>
&gt;&gt; And now the readers show all kinds of gibberish! All lines have no whitespace, save for the newline at the end. I&#39;m assuming it&#39;s at the end. <br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Sat, Mar 1, 2014 at 12:47 PM, Robert Keizer &lt;<a href="mailto:robert@keizer.ca">robert@keizer.ca</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Have you tried setting IFS ( field sep )? Also you could enable raw mode with -r.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Can you share the script?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Are the same lines failing repeatedly?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Rob<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On 2014-03-01 11:55 AM, &quot;Kevin McGregor&quot; &lt;<a href="mailto:kevin.a.mcgregor@gmail.com">kevin.a.mcgregor@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I have a main script which writes to a named pipe. Before it starts writing, it starts two other scripts which read from this pipe. The reading and writing is a list of file names, one per line. How do I ensure that each script reads one complete line from the pipe at a time (no more, no less)?<br>

&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I have a test set up, and it usually works, but sometimes a reader will get a blank line or just a &quot;/&quot; (but not any other part of a line)!<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Kevin<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt; Roundtable mailing list<br>
&gt;&gt;&gt;&gt; <a href="mailto:Roundtable@muug.mb.ca">Roundtable@muug.mb.ca</a><br>
&gt;&gt;&gt;&gt; <a href="http://www.muug.mb.ca/mailman/listinfo/roundtable" target="_blank">http://www.muug.mb.ca/mailman/listinfo/roundtable</a><br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; Roundtable mailing list<br>
&gt;&gt;&gt; <a href="mailto:Roundtable@muug.mb.ca">Roundtable@muug.mb.ca</a><br>
&gt;&gt;&gt; <a href="http://www.muug.mb.ca/mailman/listinfo/roundtable" target="_blank">http://www.muug.mb.ca/mailman/listinfo/roundtable</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
<br>
_______________________________________________<br>
Roundtable mailing list<br>
<a href="mailto:Roundtable@muug.mb.ca">Roundtable@muug.mb.ca</a><br>
<a href="http://www.muug.mb.ca/mailman/listinfo/roundtable" target="_blank">http://www.muug.mb.ca/mailman/listinfo/roundtable</a><br>
</div></div></blockquote></div><br></div>