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

Reply via email to