delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2023/04/12/03:04:08

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8CE9B385842A
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1681282995;
bh=slzem+C7LA9kSD+ayYPEc/idtZ1pA2KEuFIe18boaVM=;
h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
From;
b=ppRNmc6bWg1eO+SMgWK1/xGTZ7xY7EsQFHqROyjsi9gtxH8rc7lfVC9LEWvA35sNT
cJabMKA+kgYQj1V319P414OkOStSAfD3nfCxPExDopa20M5TN2eqiqW6l23J7gTK5B
/CSq2ompyNIEqYa6wjDCaz272LmzzjCOgQDScu/8=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 533E63858D28
X-Authority-Analysis: v=2.4 cv=XZqaca15 c=1 sm=1 tr=0 ts=6436579a
a=DxHlV3/gbUaP7LOF0QAmaA==:117 a=DxHlV3/gbUaP7LOF0QAmaA==:17
a=IkcTkHD0fZMA:10 a=yMhMjlubAAAA:8 a=bQh6vkWedRMBCkycD1sA:9 a=QEXdDO2ut3YA:10
Message-ID: <9854bbe6-aa59-6117-0d48-522684031f28@Shaw.ca>
Date: Wed, 12 Apr 2023 01:02:49 -0600
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.9.1
Subject: Re: issue when piping from a windows program
To: cygwin AT cygwin DOT com
References: <trinity-bed8517a-5458-4f9d-8ee1-6d6698fcdea7-1681197303539 AT 3c-app-mailcom-lxa08>
<1138153048 DOT 20230411174322 AT yandex DOT ru>
Organization: Inglis
In-Reply-To: <1138153048.20230411174322@yandex.ru>
X-CMAE-Envelope: MS4xfIOSd6KEj/KevydUjzA8NMUovh52NEgJnKy4vGtBW4TndG4HMKALmseIfZT2w/y0CPqjebrJotT+oiWdsfsYrR7A5b5HJcPvooHul+G1TXl7AJKTU5N2
EMhMXA2LUp3DrthwZf2h+AfATBVJTx0Rx8SBO4c+HeI788W1JzF9lX8N1CLPdpQ1SpzWhio8f3JBpTtwEsKfKrafcs0S4p/a5OQ=
X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_LOW,
RCVD_IN_MSPIKE_H2, 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
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Brian Inglis via Cygwin <cygwin AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: Brian Inglis <Brian DOT Inglis AT Shaw DOT ca>, Leonid Mironov <lvm AT royal DOT net>
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 33C73hCH023493

On 2023-04-11 08:43, Andrey Repin via Cygwin wrote:
> Greetings, Leonid Mironov!
> 
>> 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?
> 
> You don't need d2u. Use `… | iconv -f UTF16LE | tr -d '\r'`
> (Don't even need -t for iconv - it assumes current locale settings as
> default source/destination encoding.)

d2u -ul converts from utf-16le to utf-8

When I run wmic under mintty or | less it looks fine to me e.g.:

	$ wmic baseboard list full | less	# optional

but the output could benefut from \r stripping:

	$ wmic baseboard list full | tr -d '\r' | cat -A | less

https://learn.microsoft.com/en-us/windows/whats-new/deprecated-features#deprecated-features

The WMIC tool is deprecated in Windows 10, version 21H1 and the 21H1 General 
Availability Channel release of Windows Server. This tool is superseded by 
Windows PowerShell for WMI.

https://learn.microsoft.com/en-us/powershell/scripting/learn/ps101/07-working-with-wmi

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019