Re: [code] [textadept] output from spawn on Windows?

From: Mateusz Czaplinski <czapkofan.att.gmail.com>
Date: Tue, 10 Feb 2015 22:44:54 +0100

On Tue, Feb 10, 2015 at 10:41 PM, Mateusz Czaplinski <czapkofan.att.gmail.com>
wrote:

>
>
> On Tue, Feb 10, 2015 at 2:15 AM, Mitchell <m.att.foicica.com> wrote:
>
>> Hi Mateusz,
>>
>> On Tue, 10 Feb 2015, Mateusz Czaplinski wrote:
>>
>> pp=spawn('git --version',_USERHOME,ui.print,ui.print,ui.print) pp:wait()
>>> ui.print('hi')
>>>
>>> and the output I get is:
>>>
>>> hi
>>> git version 1.9.4.msysgit.2
>>>
>>> 0
>>>
>>> so, the callbacks are apparently still called async, long after the
>>> :wait()
>>> has finished. So that's probably why I wasn't able to capture anything?
>>> That doesn't seem to give me much hope as to processing the command's
>>> output and doing something useful afterwards in a synchronous way...
>>>
>>
>> Calling `pp:wait()` blocks Lua, preventing async callbacks from running
>> until after the current Lua function (which in your case includes printing
>> 'hi' first). If you want to synchronously read a process' output, use
>> `pp:read()` without `pp:wait()`.
>>
>> The simplest thing I can do is from the command entry:
>>
>> =spawn('ruby -v'):read('*a')
>>
>> This works just fine.
>>
>
> Ok, for a simple command, read() worked, thanks. But then, via read() I
> can't get the STDERR output, unfortunately, right? Nor the exit code of the
> process?
>

Hmm, so if I understand correctly, I could still do something afterwards by
adding any subsequent logic to the callbacks? So that, e.g. if I wanted to
call a few commands in sequence, each one would have the remaining ones as
nested callbacks? Something like in node.js reportedly?

Thanks,
/Mateusz.

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Tue 10 Feb 2015 - 16:44:54 EST

This archive was generated by hypermail 2.2.0 : Wed 11 Feb 2015 - 06:47:26 EST