public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: David Karr <davidmichaelkarr@gmail.com>
To: The Cygwin Mailing List <cygwin@cygwin.com>
Subject: Re: Redirecting stderr to stdout through pipe doesn't work the way it does in Linux
Date: Wed, 05 Dec 2018 18:33:00 -0000	[thread overview]
Message-ID: <CAA5t8VpcYy_tTYHTmJMmA4x3-kSJ91ZgBn0j5C=9hehKyhnxuQ@mail.gmail.com> (raw)
In-Reply-To: <37f0fb9b-5d70-ea1f-b1fc-1cd3f3ad0fa7@gmail.com>

On Wed, Dec 5, 2018 at 9:43 AM cyg Simple <cygsimple@gmail.com> wrote:

> On 12/5/2018 10:11 AM, David Karr wrote:
> > On Tue, Dec 4, 2018 at 12:52 PM Marco Atzeri <marco.atzeri@gmail.com>
> wrote:
> >
> >> Am 04.12.2018 um 21:41 schrieb David Karr:
> >>> "CYGWIN_NT-6.1 WACDTL03DK068X 2.9.0(0.318/5/3)"
> >>>
> >>> I installed a version of "kubectl" for windows, and I use it
> extensively
> >> in
> >>> Cygwin bash for scripting command-line automation. In general, this
> works
> >>> perfectly fine. I even use the same scripting in a Linux VM.
> >>>
> >>> I'm seeing an issue with one script that works fine in the Linux VM,
> but
> >>> not in Cygwin.
> >>>
> >>> The command line is approximately this:
> >>>
> >>>        kubectl exec pod -c container -i -t -- grep "string"
> >> stuff.properties
> >>> 2>&1 | sed -e 's/^propname=//'
> >>>
> >>> In Linux, this works perfectly fine.  In Cygwin, it says "stdout is
> not a
> >>> tty".
> >>>
> >>> I haven't updated my local Cygwin installation for quite a while. I'd
> >>> prefer not to, unless there is a strong chance this kind of thing would
> >> be
> >>> fixed.
> >>>
> >>
> >> as kubectl is not a Cygwin program, it is not aware of cygwin pty.
> >> You can try to use winpty to overcome the problem.
> >>
> >> https://github.com/rprichard/winpty
> >>
> >>
> >>
> > It turns out that not only had I already used winpty for similar
> > functionality, it was actually in place in the pipeline when I tried to
> do
> > this.  When I turned on debugging output, it showed that kubectl was
> > already being wrapped by winpty when it reported "stdout is not a tty".
> > However, this was one shell script wrapper deeper than I usually call it.
> > Does it matter whether winpty is called from the shell script I'm
> calling,
> > or from the script being called by the script I'm calling?
>
> Your query got me interested in looking and I believe that winpty needs
> to be at the front of all the commands so that it can communicate with
> mintty properly.  To overcome the need to remember you could add an
> alias to execute the command; `alias FOO="winpty FOO"'.
>

Sigh. What a mess. I can't get this to work.  It was easy enough when a
single script has to execute "kubectl", having "winpty" prefix that call,
but I'm trying to write a script that calls that other script, and even in
a pipeline.

If I have "winpty" prefix the call to the script that calls "kubectl", it
says:

    winpty: error: cannot start '...': Not found in PATH

When I changed it so it references the absolute path, it then says "%1 is
not a valid Win32 application. (error 0xc1)".  So, this makes it clear that
winpty can only directly execute Windows applications, which makes sense.

So how can I call a Windows application from more than just the top-level
script?

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

  reply	other threads:[~2018-12-05 18:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-04 20:41 David Karr
2018-12-04 20:52 ` Marco Atzeri
2018-12-04 21:39   ` cyg Simple
2018-12-05 14:58   ` David Karr
2018-12-05 15:11   ` David Karr
2018-12-05 17:42     ` cyg Simple
2018-12-05 18:33       ` David Karr [this message]
2018-12-05 19:43         ` cyg Simple
2018-12-05 22:25           ` David Karr
2018-12-06 16:21             ` cyg Simple
2018-12-06  0:20         ` Andrey Repin
2018-12-06  1:03           ` David Karr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAA5t8VpcYy_tTYHTmJMmA4x3-kSJ91ZgBn0j5C=9hehKyhnxuQ@mail.gmail.com' \
    --to=davidmichaelkarr@gmail.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).