delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2024/07/20/15:04:38

DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 46KJ4bGn1750684
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=j+kJ+EDg
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D23243858C41
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1721502274;
bh=6vgUxsR/tlVEA5vI6ItwzwzbzqgAEhY7luSOr1Ll6K0=;
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=j+kJ+EDg187nU7ehTpBEEoIj+1awD2alSqO/V5XyvPYxhCwsKYAWQnn5ID1a4foUA
GIr7mm0kS2hVPZqEPnn98vupaiLE4SIgpSlqL6M0xM91FZMbHA/RI6EPsDA+Iwsqag
3R7bz2ZuogTgBmRA6cKF/QpcW9rB/R5vslQpw+T0=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4B2D33858C41
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4B2D33858C41
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721502252; cv=none;
b=whsUPaYaHN8gkwbjAOyC/hQRUy6VnYO5I8kuegIoOmE5WUI51AMwFVhB8uaEDHp5wWplibP4Lcq4Ip1E01u82L0//vv3OvS3pzr8Rr2aFStVg7Lnxi+MT84hmuGMEwsDntUjXv0gxYgfpW2/EtBYwEeEMPVE24dsbf55SvLQzDE=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1721502252; c=relaxed/simple;
bh=QNLvfZVUHpoSN9BNpENXNph24qLAtwo9ryawCkWNyA4=;
h=Message-ID:Date:MIME-Version:Subject:To:From;
b=KQNxhG+H2B9jOiTvYNCnaoFjSQ0EfP8rIpYL5/0F+5Evw1pLoWYRi3QSq/2u21JMuMZCNE9V2I+uQnXfKKX8eMxC9b5s0GiQOGZkF4qlzFlsL7Ydn/5U5W/nDJsMeGCvzkwmaqBI4N0aXIK7p4bKs4LuALxmBXjqg9/HlzrI2Hg=
ARC-Authentication-Results: i=1; server2.sourceware.org
Message-ID: <6b396dd4-45f4-4039-bc40-e02366e957e1@SystematicSW.ab.ca>
Date: Sat, 20 Jul 2024 13:04:06 -0600
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Parse output of "net use", but language varies - force language
for "net use"?
To: cygwin AT cygwin DOT com
References: <CAN0SSYzW_im0Fgucbsqk6u=Cu1suSmvhJbskH8doV98mMOTtUg AT mail DOT gmail DOT com>
<CANV9t=TCFTGisXDC6UJ5zR5Bk=CiFAwFSX=sRe1H+uSwNA7BpA AT mail DOT gmail DOT com>
<CAN0SSYwLfRUFypCGSo-k5iCi24ndLQwPT=pbGvkq0ptBkui8BQ AT mail DOT gmail DOT com>
Autocrypt: addr=Brian DOT Inglis AT Shaw DOT ca; keydata=
xjMEXopx9BYJKwYBBAHaRw8BAQdAPq8FIaW+Bz7xnfyJ1gHQyf2EZo5sAwSPy/bRAcLeWl/N
I0JyaWFuIEluZ2xpcyA8QnJpYW4uSW5nbGlzQFNoYXcuY2E+wpYEExYIAD4WIQTG63sbl+cr
2nyOuZiKvQKcH1E27wUCXopx9AIbAwUJCWYBgAULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAK
CRCKvQKcH1E276DmAP91Bt8kfJhKHYb9b2sao2fxwJFsl1GlRi516WKI0OkphQEA+ULITsPs
blfzSq+GgI7q4LPfRfTLy4Oo3gorlnhnfgnOOAReinH0EgorBgEEAZdVAQUBAQdAepgIsLwm
GQicfoIBaB9xHp63MQJqVCPbgPzESTg7EEwDAQgHwn0EGBYIACYWIQTG63sbl+cr2nyOuZiK
vQKcH1E27wUCXopx9AIbDAUJCWYBgAAKCRCKvQKcH1E27+zoAP4u2ivMQBAqaMeLOilqRWgy
nV2ATImz1p2v1H5P4kBiDwD3caPK1cxU5lijzuSDCjgtIpgF/avHbjA32fxJdIRwAA==
Organization: Systematic Software
In-Reply-To: <CAN0SSYwLfRUFypCGSo-k5iCi24ndLQwPT=pbGvkq0ptBkui8BQ@mail.gmail.com>
X-Rspamd-Queue-Id: 3375E20024
X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00, BODY_8BITS,
KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,
SPF_HELO_PASS, SPF_PASS, TXREP,
UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6
X-Rspamd-Server: rspamout06
X-Stat-Signature: qe3py98opc1rjzmaryrikdb1feday1rm
X-Session-Marker: 427269616E2E496E676C69734053797374656D6174696353572E61622E6361
X-Session-ID: U2FsdGVkX184hFIbAXIPCybGbXIXqVL00rnUDTrYx0Y=
X-HE-Tag: 1721502247-506978
X-HE-Meta: U2FsdGVkX1+BTAq7bra6EJ5o32w6p8Qp7rQxc3Pnx87HiZZYZ9+naaHOiwthmn0e6I85RkcYAoYNOey4rnLrG4GonAUSi5oh021z0teX6f2flDk1d2GCxKflncOlGBvN5foeVW2t+p5XEfB+KQEUpFFnC32K2BIwjqVom2Nxgdp1XLMuG6wPaaLvmzK4aOWEfL5R5yZBIcoJK4HJH9GpMYkwELhbt9A+ZQcoOkZH0iFY2LI3hndv4/MdEde3H/856P4Bv/Ucrx9boPYUjmAfH/tJTQ15mihL6/qYZAPuP+jRam+0a6Y7KyJxT1c5Etb0oLPIHEbFUPtVNwF84viSGiu38c0V6Y0qqdskVyX4+T3rvnUysQg5Mb0UIt2znxiammhdRLuCw55Edxud5u0tWw==
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.30
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 SystematicSW DOT ab DOT ca>
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 46KJ4bGn1750684

On 2024-07-20 08:56, Mark Liam Brown via Cygwin wrote:
> On Sat, Jul 20, 2024 at 4:31 PM Bill Stewart via Cygwin
> <cygwin AT cygwin DOT com> wrote:
>>
>> On Sat, Jul 20, 2024 at 7:45 AM Mark Liam Brown via Cygwin wrote:
>>
>> I am trying to parse the output of "net use" in a bash script, but hit
>>> a roadblock:
>>> The output of "net use" changes with the language of the system
>>> (English, Danish, French, ...), so parsing becomes nearly impossible
>>>
>>> How can I force the language used by "net use" to English, even if the
>>> system default language is Danish or French?
>>>
>>
>> This sounds like an XY problem[1] to me....
>>
>> What is the goal you're trying to accomplish? Enumerate existing
>> connections? Get drive mappings?
> 
> Basically I need every bit of information out of "net use", "net
> config", "net statistics", "net view" and so on, parse it in bash or
> perl, process it in bash, and output it in JSON format from the bash
> script for our (Linux-based) admin report interface.

Hi Mark,

Two suggestions for getting the information you need:

- set up a local user admin account locale with English language and regional 
settings

- look into registry virtualization, where you can temporarily replace part of 
the user registry with a saved hive, containing the keys to be changed.

You can also make these changes with group policy editor.

Below is the Cygwin view of significant user locale registry entries (easier to 
use with path lookup and completion); you can also use Windows `reg query`:

$ regtool list -v /proc/registry/HKEY_CURRENT_USER/Control\ 
Panel/International/User\ Profile/
en-CA\ ()
en-GB\ ()
en-US\ ()
Languages (REG_MULTI_SZ) = "en-CA", "en-GB", "en-US"
ShowAutoCorrection (REG_DWORD) = 0x00000001 (1)
ShowTextPrediction (REG_DWORD) = 0x00000001 (1)
ShowCasing (REG_DWORD) = 0x00000001 (1)
ShowShiftLock (REG_DWORD) = 0x00000001 (1)
UserLocaleFromLanguageProfileOptOut (REG_DWORD) = 0x00000001 (1)
HttpAcceptLanguageOptOut (REG_DWORD) = 0x00000001 (1)

$ regtool list -v /proc/registry/HKEY_CURRENT_USER/Control\ Panel/International/Geo/
Nation (REG_SZ) = "39"
Name (REG_SZ) = "CA"

$ regtool list -v /proc/registry/HKEY_CURRENT_USER/Control\ Panel/International/
Calendars\ ()
Geo\ ()
LanguageComponentsAvailable\ ()
User Profile\ ()
User Profile System Backup\ ()
🌎🌏🌍\ ()
s1159 (REG_SZ) = "AM"
s2359 (REG_SZ) = "PM"
sCurrency (REG_SZ) = "$"
sDecimal (REG_SZ) = "."
sGrouping (REG_SZ) = "3;0"
sList (REG_SZ) = ","
sMonDecimalSep (REG_SZ) = "."
sMonGrouping (REG_SZ) = "3;0"
sMonThousandSep (REG_SZ) = ","
sNativeDigits (REG_SZ) = "0123456789"
sNegativeSign (REG_SZ) = "-"
sPositiveSign (REG_SZ) = ""
sThousand (REG_SZ) = ","
sTime (REG_SZ) = ":"
iCalendarType (REG_SZ) = "1"
iCountry (REG_SZ) = "1"
iCurrDigits (REG_SZ) = "2"
iCurrency (REG_SZ) = "0"
NumShape (REG_SZ) = "2"
iFirstWeekOfYear (REG_SZ) = "0"
iLZero (REG_SZ) = "1"
iNegNumber (REG_SZ) = "1"
iPaperSize (REG_SZ) = "1"
iTimePrefix (REG_SZ) = "0"
Locale (REG_SZ) = "00001009"
LocaleName (REG_SZ) = "en-CA"
sCountry (REG_SZ) = "Canada"
sDate (REG_SZ) = "-"
sLanguage (REG_SZ) = "ENC"
sLongDate (REG_SZ) = "yyyy MMMM dd dddd"
sShortDate (REG_SZ) = "yyyy-MM-dd"
sTimeFormat (REG_SZ) = "HH:mm:ss"
sShortTime (REG_SZ) = "HH:mm"
sYearMonth (REG_SZ) = "MMMM, yyyy"
iDate (REG_SZ) = "2"
iDigits (REG_SZ) = "3"
iFirstDayOfWeek (REG_SZ) = "0"
iMeasure (REG_SZ) = "0"
iNegCurr (REG_SZ) = "1"
iTime (REG_SZ) = "1"
iTLZero (REG_SZ) = "1"

$ regtool list -v /proc/registry/HKEY_CURRENT_USER/Control\ 
Panel/International/🌎🌏🌍/
Calendar (REG_SZ) = "Gregorian"

$ regtool list -v /proc/registry/HKEY_CURRENT_USER/Control\ 
Panel/International/Calendars/TwoDigitYearMax/
1 (REG_SZ) = "2099"
2 (REG_SZ) = "2099"
9 (REG_SZ) = "2099"
10 (REG_SZ) = "2099"
11 (REG_SZ) = "2099"
12 (REG_SZ) = "2099"

-- 
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