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

From: Mitchell <m.att.foicica.com>
Date: Mon, 9 Feb 2015 09:26:16 -0500 (EST)

Hi Mateusz,

On Sat, 7 Feb 2015, Mateusz Czaplinski wrote:

> Hi,
>
> I tried to use spawn() on Windows, and retrieve some output from it, but
> all seems empty. Is it supposed to work on Windows (7, x64)? Maybe I'm
> using it wrong - could you please maybe show me a full command that's
> expected to work to capture output? (To be more precise: the command seemed
> to run successfully in itself, only I couldn't capture the output.) I tried
> something like below:
> local pout, perr, pcode = '', '', nil
> local proc = spawn(my_command, my_workdir,
> function(out) pout = pout + out end,
> function(out) perr = perr + out end,
> function(code) pcode = code end)
> local s, errc, err = proc:read '*a'
> if s==nil then
> ui.print('error: '..errc..' '..err)
> end
> ui.print('s=', s)
> ui.print('pout=', pout)
> ui.print('perr=', perr)
> ui.print('pcode=', pcode)
> In the [Message Buffere] they all show empty, and pcode shows nil.
> Also tried to add proc:wait() before or after the read(), but doesn't seem
> to help either.

You are using `proc:read()`, so the stdout and stderr callbacks will never
populate `pout` and `perr` (it wouldn't work anyway since you should be
using the concatenation operator `..` instead of numeric addition `+`).
Try using `proc:wait()` without any call to `proc:read()`.

I've entered the following command into the command entry and gotten the
proper output in the message buffer:

   spawn('ruby -v', nil, ui.print, ui.print, ui.print)

(No `wait()`, `read()`, etc. I just let the asynchronous process do its
thing.)

Cheers,
Mitchell

-- 
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 Mon 09 Feb 2015 - 09:26:16 EST

This archive was generated by hypermail 2.2.0 : Tue 10 Feb 2015 - 06:46:03 EST