DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 46KJniUi1761671
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=XbKrxaS9
X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CAE28385DDD7
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1721504981;
	bh=G1/lx1gXhDZ4VC2uXOrEJhzR2S9NoFlFurImciJU+9U=;
	h=Date:To:Cc:Subject:References:In-Reply-To:List-Id:
	 List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:
	 From:Reply-To:From;
	b=XbKrxaS93HbuMiar8EEfPnocGmdeFpmll0O/F/FGXFDqtMdXMAhnty7gSwDWGhsHH
	 rkc3rh5TOosfdZ0R07T3QNpNXdDfBesFeavSxF4mGGKeeksCJKu6rrQlyBm84UcgTO
	 uGJLkE5hTWY+f0YGK6/mnV3t4Em8ILqHgGjP2mrg=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E8FDD3858D20
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E8FDD3858D20
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721504960; cv=none;
 b=HktncGEhKKb/bqYpNbpwOAynnPSAVueDl+Urmn6vQY4qHLer+eStXBT+JOXWjR3+Zmv6TMRT1zyTIyg1z8EIenNTxMigQTMtexw5eFVtYTkJQ/JJtXIs+vTuJBoW5XtwyniModYFTaksR5GfdkpkAmZwDabrD1M12mr5EtnL40k=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
 t=1721504960; c=relaxed/simple;
 bh=TbFl+mj/Y/kyas0BDlhMdOVpLKpmJZtMLawMuTHfi9E=;
 h=Date:From:To:Subject:Message-ID:MIME-Version;
 b=BEzJOSQLlKnYHB1hjVJ6QZCwd/i9JGtmLz1XUdWc6LGVvtXDIZZHL4g/n/nfo9/S+WauBZo70f2ao71n0moK5k5GlaGg9PnAgInVxsoZ7JaXQEwWQn88b/ZwMEoJHCyviTRhtupVnQEwlm3mo1a+Fy4N3e+Ni6tbzsJqSKlxRak=
ARC-Authentication-Results: i=1; server2.sourceware.org
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
 server2.sourceware.org
X-Spam-Language: en
X-Spam-Relay-Country: 
X-Spam-DCC: B=MGTINTERNET; R=smtp1.atof.net 1170; Body=1 Fuz1=1 Fuz2=1
X-Spam-RBL: 
X-Spam-PYZOR: Reported 0 times.
Date: Sat, 20 Jul 2024 15:49:05 -0400
To: Mark Liam Brown <brownmarkliam@gmail.com>
Cc: cygwin@cygwin.com
Subject: Re: Parse output of "net use", but language varies - force language
 for "net use"?
Message-ID: <ZpwT9_NzYVdTHNR7@xps13>
References: <CAN0SSYzW_im0Fgucbsqk6u=Cu1suSmvhJbskH8doV98mMOTtUg@mail.gmail.com>
 <CANV9t=TCFTGisXDC6UJ5zR5Bk=CiFAwFSX=sRe1H+uSwNA7BpA@mail.gmail.com>
 <CAN0SSYwLfRUFypCGSo-k5iCi24ndLQwPT=pbGvkq0ptBkui8BQ@mail.gmail.com>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <CAN0SSYwLfRUFypCGSo-k5iCi24ndLQwPT=pbGvkq0ptBkui8BQ@mail.gmail.com>
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS,
 SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.30
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: "gs-cygwin.com--- via Cygwin" <cygwin@cygwin.com>
Reply-To: gs-cygwin.com@gluelogic.com
Content-Type: text/plain; charset="utf-8"
Errors-To: cygwin-bounces~archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie.com@cygwin.com>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 46KJniUi1761671

On Sat, Jul 20, 2024 at 04:56:56PM +0200, 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.
> 
> Mark
> -- 
> IT Infrastructure Consultant
> Windows, Linux

Hello Mr Consultant.  You seem to have a NIH syndrome that you are
approaching your problem as if you are the first person to ever do this,
and therefore you are writing everything yourself, from scratch.
Do you honestly think you are the first person who would like the info
displayed by 'net use' in some form of structured data?

Using Powershell and its formatting options, as posted in Henry's
response, is probably the best answer *for scripting*.

If using Perl *for scripting*, there are numerous Perl modules such as
https://metacpan.org/pod/Win32::NetResource

If you were to try using a search engine more effectively, you might also
find C++ libraries or C# APIs to access all that info as structured data,
instead of trying to parse the `net use` command line output using bash,
and trying to fight with the registry settings to affect `net use`
display of the data.

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

