From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta001.cacentral1.a.cloudfilter.net (omta001.cacentral1.a.cloudfilter.net [3.97.99.32]) by sourceware.org (Postfix) with ESMTPS id 533E63858D28 for ; Wed, 12 Apr 2023 07:02:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 533E63858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=Shaw.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=shaw.ca Received: from shw-obgw-4001a.ext.cloudfilter.net ([10.228.9.142]) by cmsmtp with ESMTP id m8GLp0FwGuZMSmUVGpKhSB; Wed, 12 Apr 2023 07:02:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1681282970; bh=zE5RvFyOSY8bzUKENpBkN5R1VzfjGYIHpxmNAF97Obc=; h=Date:Reply-To:Subject:To:Cc:References:From:In-Reply-To; b=VtPBTtLICkwU1Jl5QfG7imyxES6oelKdzZukPkh5Po50I6lPiKCaG4b2YEBFZ9shT DgavQGdSB1MjihwimHppRHd9pilotuJ0XrAZpl3b7gDJv4CaUikY4poJ3IO4rnSUa/ cRB02ftbsxN5amLLOuSlQR3hqfc663zMFsnwPdPVWZLJGwSGp9ivuYNTxGtAOToTiM 8RJlqBmov8sxGGrn6Vi6ParG9JWQSHqL8nJ2MVxR6SstCIkrqjfoNxG+ZiLCF8loF/ H9A0HOUIeWB8JlIPMMnscIywclXL5IxURdL5z7xZ8JeTGA0KYKKxXCpVdqO27r4wjG NUTgm837AjVHA== Received: from [10.0.0.5] ([184.64.102.149]) by cmsmtp with ESMTP id mUVGpCtM7HFsOmUVGpQrw9; Wed, 12 Apr 2023 07:02:50 +0000 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 Reply-To: cygwin@cygwin.com Subject: Re: issue when piping from a windows program Content-Language: en-CA To: cygwin@cygwin.com Cc: Leonid Mironov References: <1138153048.20230411174322@yandex.ru> From: Brian Inglis Organization: Inglis In-Reply-To: <1138153048.20230411174322@yandex.ru> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 List-Id: 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