Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion How to open interactive terminal apps with child_process?

Received: by 10.59.7.234 with SMTP id df10mr789976ved.23.1348225397897;
        Fri, 21 Sep 2012 04:03:17 -0700 (PDT)
X-BeenThere: nodejs@googlegroups.com
Received: by 10.221.0.70 with SMTP id nl6ls2524845vcb.5.gmail; Fri, 21 Sep
 2012 04:03:08 -0700 (PDT)
Received: by 10.59.1.102 with SMTP id bf6mr838304ved.21.1348225388977;
        Fri, 21 Sep 2012 04:03:08 -0700 (PDT)
Received: by 10.59.1.102 with SMTP id bf6mr838302ved.21.1348225388957;
        Fri, 21 Sep 2012 04:03:08 -0700 (PDT)
Return-Path: <jcog...@gmail.com>
Received: from mail-vb0-f44.google.com (mail-vb0-f44.google.com [209.85.212.44])
        by gmr-mx.google.com with ESMTPS id r14si470299vdu.1.2012.09.21.04.03.08
        (version=TLSv1/SSLv3 cipher=OTHER);
        Fri, 21 Sep 2012 04:03:08 -0700 (PDT)
Received-SPF: pass (google.com: domain of jcog...@gmail.com designates 209.85.212.44 as permitted sender) client-ip=209.85.212.44;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jcog...@gmail.com designates 209.85.212.44 as permitted sender) smtp.mail=jcog...@gmail.com; dkim=pass header...@gmail.com
Received: by vbbfc26 with SMTP id fc26so4285393vbb.3
        for <nodejs@googlegroups.com>; Fri, 21 Sep 2012 04:03:08 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :content-type;
        bh=bLv1jjixN8ehk3p3BzdACrJ4QYPBjkrB1NFgGNCaPUc=;
        b=OCqQFh6/q3c/PEHNUa/l0AFXLMqV6n0L8s+3+9LXI3kcnNPMZMN7kZo02g8KclKAw3
         /otbRZFKaRSK2GyD0p05yS4gttyybp0HTmQirA7AT82qFz5RYXBiq9dw2xwiAtR8RM+l
         vtdJKlx2NOZx/OYpmhgeu2QrxaFnoPMeq2EWRn0ykhQLO5vx028hngkSDpSVCXs0ImA1
         BT/9f5Cj0cC1XrGVd68v4CbEVws8dBYVRSHJxi+tTO8ngIWdmbaL2h9LOer7G1u+6GMY
         tRV8Gdw6xVHjeqyFsDo7FH6mDqHUaPBLfC/qiXNFQ4FZ/q/gQM4pWg5K7jt13d4JjHUX
         qJvw==
MIME-Version: 1.0
Received: by 10.58.58.144 with SMTP id r16mr2822740veq.52.1348225388619; Fri,
 21 Sep 2012 04:03:08 -0700 (PDT)
Received: by 10.58.211.6 with HTTP; Fri, 21 Sep 2012 04:03:08 -0700 (PDT)
In-Reply-To: <CALm1c-EFBrh6zQYjcmWEWdxS7sf9smoG1-11-XzEjGEQUAj...@mail.gmail.com>
References: <CALm1c-EFBrh6zQYjcmWEWdxS7sf9smoG1-11-XzEjGEQUAj...@mail.gmail.com>
Date: Fri, 21 Sep 2012 13:03:08 +0200
Message-ID: <CALm1c-E70W3ZvMtFuT-ga5KUtr+udAreTpezWQihBn-aV=w...@mail.gmail.com>
Subject: Re: How to open interactive terminal apps with child_process?
From: James Coglan <jcog...@gmail.com>
To: Node list <nodejs@googlegroups.com>
Content-Type: multipart/alternative; boundary=047d7b4140c65da8a304ca342f06

--047d7b4140c65da8a304ca342f06
Content-Type: text/plain; charset=ISO-8859-1

On 21 September 2012 12:40, James Coglan <jcog...@gmail.com> wrote:

> I'd like to have my command-line Node program invoke another interactive
> shell program (in this case w3m, but think vim, less, and so on) as a child
> process so that it appears in my terminal. I thought I could do that like
> this:
>
> require('child_process').execFile('w3m', ['http://www.google.com'],
> {stdio: 'inherit'})
>
> But it turns out that doesn't work. Is this possible?
>

This is a bit better in that it displays the output from w3m, but it's not
color formatted (I guess because its stdin is not a tty) and I can't
interact with it properly:

var cp  = require('child_process'),
    w3m = cp.execFile('w3m', ['http://www.google.com']);

process.stdin.pipe(w3m.stdin);
w3m.stdout.pipe(process.stdout);

So I need to make w3m know it's writing to a tty, and forward every
keystroke from Node to the child process. I tried
process.stdin.setRawMode(true) but this just locked the process up and
CTRL-C and CTRL-Z did not work.

--047d7b4140c65da8a304ca342f06
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div class=3D"gmail_quote">On 21 September 2012 12:40, James Coglan <span d=
ir=3D"ltr">&lt;<a href=3D"mailto:jcog...@gmail.com" target=3D"_blank">jcogl=
a...@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>I&#39;d like to have my command-line Node program invoke another inter=
active shell program (in this case w3m, but think vim, less, and so on) as =
a child process so that it appears in my terminal. I thought I could do tha=
t like this:</div>

<div><br></div><div>require(&#39;child_process&#39;).execFile(&#39;w3m&#39;=
, [&#39;<a href=3D"http://www.google.com" target=3D"_blank">http://www.goog=
le.com</a>&#39;], {stdio: &#39;inherit&#39;})</div><div><br></div><div>But =
it turns out that doesn&#39;t work. Is this possible?</div>
</blockquote><div><br></div><div>This is a bit better in that it displays t=
he output from w3m, but it&#39;s not color formatted (I guess because its s=
tdin is not a tty) and I can&#39;t interact with it properly:</div><div>
<br></div><div>var cp =A0=3D require(&#39;child_process&#39;),</div><div>=
=A0 =A0 w3m =3D cp.execFile(&#39;w3m&#39;, [&#39;<a href=3D"http://www.goog=
le.com">http://www.google.com</a>&#39;]);</div><div><br></div><div>process.=
stdin.pipe(w3m.stdin);</div>
<div>w3m.stdout.pipe(process.stdout);</div><div><br></div><div>So I need to=
 make w3m know it&#39;s writing to a tty, and forward every keystroke from =
Node to the child process. I tried process.stdin.setRawMode(true) but this =
just locked the process up and CTRL-C and CTRL-Z did not work.=A0</div>
</div>

--047d7b4140c65da8a304ca342f06--