From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id CC422385800A for ; Tue, 11 Apr 2023 09:02:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CC422385800A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-x42b.google.com with SMTP id o18so6766022wro.12 for ; Tue, 11 Apr 2023 02:02:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1681203726; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=yf5YMCDkhHtJj07OkP3uYqzURpNQrQfD/A6WomIJvsQ=; b=OOHHaF0tZWoiwh0wvG/wTI+N6UZ+Am2WLQ7hRl+otR6sxv9M3t4aIDKdvT24w8BjRl LK54/W2+f8XO0llxP5ch2rY7WpQIhAIKlRaLrMLsIOD82oT34a0SIhkhimqxtsht8X+3 N4vvmoyf5vIicHeEA6s2Imo/fV50aNNZAJkDL6UfdPtKZKV/bLqJvy8EDnFugtKikpKp LH3S4iMYuvgdNFlfLT95HGUR1xZn0mOVaQeytaZXh1K6ks5Pd9cJCslbyLY7hrfsg+bX fDAkAg/2ZdPXCR9S6Ix+o0KwgqpBUEuHJYlB10eqVP5tt70YiQZGyvyzq6G6+FSzRjp6 ZkOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681203726; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yf5YMCDkhHtJj07OkP3uYqzURpNQrQfD/A6WomIJvsQ=; b=TjAVUOdVDcdqU1n1G12nOEGahspSJuphvN11SyJL36/1TrVtdeMA8kBMYYAO5nqcxY zrffNCTAxA+IBzIdq15OfdcZozFjmZptdK1/Wb1b1sjTrI4iQRV3E0YcxBfJg0XojTwy r4LboLYqjwxaFa8ejekqxqcb0Ib/HKlx28aLTJfOvxObfRXnHcCRifh6RG7UnrXto7rb taZY2fBP702DI3/Z0vz8pHc19/OgJusHSfFDH/YWJGpztlJ0BjNdaPBUDQB+TGdw1qSI gVgtnYayER7udi+GBMhSloiP8U77iP4chlZNm6hy8++zI6r3q6aG6fTALwxSUQibnuPH DalA== X-Gm-Message-State: AAQBX9cAH6I0ZZpNtduRz3VFxMY7Cao+Yfnd2S57g19xQc5eEcUtciJG STXO2ME7RPJREjkKxZM/jEcsh1K0vWLNYA== X-Google-Smtp-Source: AKy350a/hdvrgq7HmMSim4BALs6ywFFgsrYXBf6L8JoAEhWPJ7f4IRKvl98pR5mfr7j1hj3/FIWOfQ== X-Received: by 2002:a5d:60c1:0:b0:2ce:adbf:cb14 with SMTP id x1-20020a5d60c1000000b002ceadbfcb14mr1322939wrt.28.1681203726401; Tue, 11 Apr 2023 02:02:06 -0700 (PDT) Received: from ?IPV6:2001:a61:12fb:6801:913e:9832:1e2e:fa7f? ([2001:a61:12fb:6801:913e:9832:1e2e:fa7f]) by smtp.gmail.com with ESMTPSA id i5-20020adff305000000b002efb4dc5a5fsm10155916wro.7.2023.04.11.02.02.05 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Apr 2023 02:02:05 -0700 (PDT) Message-ID: <93787f32-eb6d-92ea-e5bb-8018c35717cc@gmail.com> Date: Tue, 11 Apr 2023 11:02:04 +0200 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 Content-Language: it To: cygwin@cygwin.com References: From: Marco Atzeri In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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 11.04.2023 09:15, Leonid Mironov via Cygwin 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' > use "iconv" to change the codification and than d2u for the line termination $ iconv -f UTF16 -t UTF8 file ChargeRate Charging RemainingCapacity Voltage 0 FALSE 0 0 $ iconv -f UTF16 -t UTF8 file |od -c 0000000 C h a r g e R a t e C h a r 0000020 g i n g R e m a i n i n g C 0000040 a p a c i t y V o l t a g e 0000060 \r \n 0 0000100 F A L S E 0 0000120 0 0000140 \r \n 0000150 $ iconv -f UTF16 -t UTF8 file |d2u | od -c 0000000 C h a r g e R a t e C h a r 0000020 g i n g R e m a i n i n g C 0000040 a p a c i t y V o l t a g e 0000060 \n 0 F 0000100 A L S E 0 0000120 0 0000140 \n 0000146