<div dir="ltr">Oh, I meant to say that I think that process*/ports can make things easier than system for this kind of thing. read-string-evt is more for if you want to get good performance for high-throughput streams, which it seems like isn&#39;t an issue here. This different seems unlikely to help with whatever is going wrong.<div>
<br></div><div style>I don&#39;t see that you&#39;re closing the ports anywhere, so maybe there is something like that happening in your real script. Make sure that you close everything as soon as you know there is no more data. Otherwise, I&#39;m just not sure what&#39;s going wrong.</div>
<div style><br></div><div style>As for process* and system*: they will work, I think, unless the strings you put in the &quot;~a&quot;s are multiple arguments and you can&#39;t do that parsing yourself. You&#39;d do something like</div>
<div style><br></div><div style>  (system* &quot;/usr/bin/instruments&quot; &quot;-t&quot; (path-&gt;string instruments-path) (path-&gt;string app-path) &quot;-e&quot; &quot;UIASCRIPT&quot; (path-&gt;string script-path))</div>
<div style><br></div><div style>roughly.</div><div style><br></div><div style>Robby</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 16, 2013 at 7:27 PM, Nick Shelley <span dir="ltr">&lt;<a href="mailto:nickmshelley@gmail.com" target="_blank">nickmshelley@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I tried &quot;file-stream-buffer-mode&quot; on the stdout port and that didn&#39;t help. That seems to be the only port that will work with that method.</div>
<div><br></div><div>I also realize I misled you when I put &quot;<span style="font-family:arial,sans-serif;font-size:13px">&lt;script-that-logs-to-console&gt;&quot; as a placeholder in the code. Really it is a command of the form </span><font face="arial, sans-serif">(format &quot;instruments -t ~a \&quot;~a\&quot; -e UIASCRIPT ~a&quot; ...) where two of the three ~a arguments are passed to Racket through the command-line. If I understand correctly, process* and system* won&#39;t work with this form.</font></div>


<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">After experimenting a bunch unsuccessfully, I tried putting the system call before I created the ports and without a parameterized current-output-port. The results I see are that for the first system call I get real-time logs to the console, then with the next one the tests repeat, but the logs don&#39;t come until the end.</font></div>


<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">I even tried Neil&#39;s suggested approach in case that made a difference. Aside from the fact that it has the same buffering problem, I never get the eof event, so I don&#39;t know when to terminate the sync loop. Here&#39;s the code:</font></div>


<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><div class="im"><div>  (define-values (in out) (make-pipe))</div><div>  (define stdout (current-output-port))</div><div>  (define string-port (open-output-string))</div>


</div><div>  (process/ports out #f #f (format &quot;instruments -t ~a \&quot;~a\&quot; -e UIASCRIPT ~a&quot; instruments-path app-path script-path))</div><div>  (let loop ([data (sync (read-string-evt 1 in))])</div><div>
    (unless (eof-object? data)</div>

<div>      (display (format &quot;data: [~a]&quot; data) stdout)</div><div>      (display data string-port)</div><div>      (loop (sync (read-string-evt 1 in)))))</div><div class="im"><div>  (printf &quot;~n~nresults: ~a~n&quot; (get-output-string string-port))</div>


<div><br></div></div><div>With this I get the delayed logs (each letter in brackets per sync event) and then the program hangs waiting for an eof that never comes. Out of curiosity, why did both of you recommend this approach over the system approach? Either I&#39;m doing it completely wrong or I just can&#39;t see the advantage.</div>


</font></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 16, 2013 at 5:08 PM, Neil Van Dyke <span dir="ltr">&lt;<a href="mailto:neil@neilvandyke.org" target="_blank">neil@neilvandyke.org</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You can try &quot;file-stream-buffer-mode&quot; on the port.<br>
<br>
Neil V.<br>
<br>
</blockquote></div><br></div>
</div></div><br>____________________<br>
  Racket Users list:<br>
  <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br></blockquote></div><br></div>