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@cygwin.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

Reply via email to