<div dir="ltr"><div>I doubt this will satisfy you, but shell command has it ready for you.</div><div><br></div><div>Jussi<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 19, 2019 at 12:35 AM Tobias Boege <<a href="mailto:taboege@gmail.com">taboege@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Mon, 18 Mar 2019, Tobias Boege wrote:<br>
> How is it done properly? I really just want an "Exec ... To sOut", but with<br>
> the option to pipe something into the process when it starts.<br>
> <br>
<br>
I found this one using a Read event and a global variable. At least<br>
it doesn't need explicit Waits with arbitrary delay values:<br>
<br>
  Private $sOut As String<br>
<br>
  Private Sub Run(aCmd As String[], sInput As String)<br>
    Dim hProc As Process<br>
<br>
    $sOut = ""<br>
    hProc = Exec aCmd For Read Write As "Process"<br>
    Write #hProc, sInput<br>
    hProc.CloseInput()<br>
    hProc.Wait()<br>
    Return $sOut<br>
  End<br>
<br>
  Public Sub Process_Read()<br>
    Dim sBuf As String<br>
<br>
    sBuf = Read #Last, -4096<br>
    $sOut &= sBuf<br>
  End<br>
<br>
I'm still curious if you can avoid the Read event. (I suppose if you're<br>
really clever you can avoid the global $sBuf by using the Process' Tag<br>
instead...) But still: is there a way to read a process imperatively as<br>
nicely as the Read event allows you to?<br>
<br>
Regards,<br>
Tobi<br>
<br>
-- <br>
"There's an old saying: Don't change anything... ever!" -- Mr. Monk<br>
<br>
----[ Gambas mailing-list is hosted by <a href="https://www.hostsharing.net" rel="noreferrer" target="_blank">https://www.hostsharing.net</a> ]----<br>
</blockquote></div>