From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from conssluserg-05.nifty.com (conssluserg-05.nifty.com [210.131.2.90]) by sourceware.org (Postfix) with ESMTPS id 5ABED3858D28 for ; Wed, 12 Apr 2023 08:56:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5ABED3858D28 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=nifty.ne.jp Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=nifty.ne.jp Received: from HP-Z230 (aj135041.dynamic.ppp.asahi-net.or.jp [220.150.135.41]) (authenticated) by conssluserg-05.nifty.com with ESMTP id 33C8uBog021131; Wed, 12 Apr 2023 17:56:11 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-05.nifty.com 33C8uBog021131 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp; s=dec2015msa; t=1681289771; bh=fhfc+Zu944snAGkfOVCXOlaCEa9yrPKiVCKg0ynW52U=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NjoRYMSWA0j0UXSm1WfEtKyeeeyKrZGYVvuAYhW0CJu3bel4nJgfhLxaVRfguFPpk pxvazRiezzIhXhrYq+WXRc7I6XJZKY4/XPq9MXT73oO4B41B5EOdfIZKRHy2sRRnsx t5debRh5MPVs8HL+6Y7hfCciiVgLKDxEhs3o45fbUwvqQq3RXMCBOZQrEJjk9hpLRP p7r7sOpaT1RCVNWxFZFU2gIsxbGQEKtkbAO7VNDVm9P1PVDiB+ZBhcZ6ORXz9IAMqo kriOGfhnMVoyJwR5FArTILyDGQUxx/gx3L/yeZgAtCa68R9QekPmg2aVzhR6XIEbTx dKFoP+BG7cMrQ== X-Nifty-SrcIP: [220.150.135.41] Date: Wed, 12 Apr 2023 17:56:11 +0900 From: Takashi Yano To: cygwin@cygwin.com Cc: Leonid Mironov Subject: Re: issue when piping from a windows program Message-Id: <20230412175611.66d4907526f579de8a9245cc@nifty.ne.jp> In-Reply-To: References: X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, 11 Apr 2023 09:15:03 +0200 Leonid Mironov wrote: > I am trying to feed the output of wmic.exe - a windows console program, to cygwin bash script. > wmic.exe produces UTF16LE output with BOM and CR/LFs, so I am using dos2unix to convert it. > The problem is that when I write wmic.exe output to a file and then use dos2unix to convert this file > I get the expected result - ASCII file with LFs, I get the same result when I pipe this file to dos2unix, > but when I pipe wmic.exe output directly to dos2unix I get ASCII file with CR/LFs and an extra empty line. > Cygwin is up to date, windows 10. What gives? > > Here are the hexdumps > > of 'wmic /NAMESPACE:\\\\root\\WMI PATH BatteryStatus get charging,voltage,remainingcapacity,chargerate>file' > > 00000000 ff fe 43 00 68 00 61 00 72 00 67 00 65 00 52 00 |..C.h.a.r.g.e.R.| > 00000010 61 00 74 00 65 00 20 00 20 00 43 00 68 00 61 00 |a.t.e. . .C.h.a.| > 00000020 72 00 67 00 69 00 6e 00 67 00 20 00 20 00 52 00 |r.g.i.n.g. . .R.| > 00000030 65 00 6d 00 61 00 69 00 6e 00 69 00 6e 00 67 00 |e.m.a.i.n.i.n.g.| > 00000040 43 00 61 00 70 00 61 00 63 00 69 00 74 00 79 00 |C.a.p.a.c.i.t.y.| > 00000050 20 00 20 00 56 00 6f 00 6c 00 74 00 61 00 67 00 | . .V.o.l.t.a.g.| > 00000060 65 00 20 00 20 00 0d 00 0a 00 30 00 20 00 20 00 |e. . .....0. . .| > 00000070 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 | . . . . . . . .| > 00000080 20 00 46 00 41 00 4c 00 53 00 45 00 20 00 20 00 | .F.A.L.S.E. . .| > 00000090 20 00 20 00 20 00 33 00 37 00 37 00 33 00 34 00 | . . .3.7.7.3.4.| > 000000a0 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 | . . . . . . . .| > 000000b0 20 00 20 00 20 00 20 00 20 00 20 00 31 00 32 00 | . . . . . .1.2.| > 000000c0 37 00 34 00 30 00 20 00 20 00 20 00 20 00 0d 00 |7.4.0. . . . ...| > 000000d0 0a 00 |..| > 000000d2 > > of wimic>file followed by dos2unix > 00000000 43 68 61 72 67 65 52 61 74 65 20 20 43 68 61 72 |ChargeRate Char| > 00000010 67 69 6e 67 20 20 52 65 6d 61 69 6e 69 6e 67 43 |ging RemainingC| > 00000020 61 70 61 63 69 74 79 20 20 56 6f 6c 74 61 67 65 |apacity Voltage| > 00000030 20 20 0a 30 20 20 20 20 20 20 20 20 20 20 20 46 | .0 F| > 00000040 41 4c 53 45 20 20 20 20 20 33 37 37 33 34 20 20 |ALSE 37734 | > 00000050 20 20 20 20 20 20 20 20 20 20 20 20 31 32 37 34 | 1274| > 00000060 30 20 20 20 20 0a |0 .| > 00000066 > > and of wimic|dos2unix > > 00000000 43 68 61 72 67 65 52 61 74 65 20 20 43 68 61 72 |ChargeRate Char| > 00000010 67 69 6e 67 20 20 52 65 6d 61 69 6e 69 6e 67 43 |ging RemainingC| > 00000020 61 70 61 63 69 74 79 20 20 56 6f 6c 74 61 67 65 |apacity Voltage| > 00000030 20 20 0d 0a 30 20 20 20 20 20 20 20 20 20 20 20 | ..0 | > 00000040 46 41 4c 53 45 20 20 20 20 20 33 37 37 33 34 20 |FALSE 37734 | > 00000050 20 20 20 20 20 20 20 20 20 20 20 20 20 31 32 37 | 127| > 00000060 34 30 20 20 20 20 0d 0a 0d 0a |40 ....| > 0000006a This is not cygwin problem. Please try the following in command prompt without cygwin. wmic > wmic_redirect.txt wmic | more > wmic_pipe.txt Then, open both text file using binary editor. wmic_redirect.txt has \r\n in UTF16 encoding, however, you will find wmic_pipe.txt has abnormal line endings. -- Takashi Yano