delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/01/23/08:05:38

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:reply-to:message-id:to:subject
:in-reply-to:references:mime-version:content-type
:content-transfer-encoding; q=dns; s=default; b=DL70oXLoqCgxCvxh
cVT/5eIMnrUgxm/+5J399Fe1ctgoA0AZFIjrm7DC7HY3Kj+OYT3RjsCg/yaZH/w8
KP+T+JHI3ozkgUC47mSguByIu46Ac/HNwHzNE9RlzESErektgzddAy2cuiFXV4pK
Hr+BEoUo6qC3KZjWzeTDcu6qrYo=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:reply-to:message-id:to:subject
:in-reply-to:references:mime-version:content-type
:content-transfer-encoding; s=default; bh=dqG+vBMxU2eie98q0/qFtr
RCj/Q=; b=YCkNT6DD9w5CsnEmkrfEWFemjwqmmMrjJDTbY6xZxhhyfTgoIel+Rw
sPK1Rk0qcwRCA3cBsXzNPHrL3AgjHGbHslIxozMwkHJQYMN1w5TfTZyGhglPsn5g
/qPEdsuvBOXaCrtO0wK34bbsqkDWEQN0HjBVtFYM8H0MmolkplHfU=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: Yes, score=5.8 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,KAM_THEBAT,RCVD_IN_PSBL,SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=H*UA:Bat!, H*x:Bat!, H*UA:Home, H*x:Home
X-HELO: smtp.ht-systems.ru
Date: Sat, 23 Jan 2016 15:52:24 +0300
From: Andrey Repin <anrdaemon AT yandex DOT ru>
Reply-To: cygwin AT cygwin DOT com
Message-ID: <862202948.20160123155224@yandex.ru>
To: Kenneth Wolcott <kennethwolcott AT gmail DOT com>, cygwin AT cygwin DOT com
Subject: Re: Using Perl on Cygwin; how to prevent display of unwanted usage/error message?
In-Reply-To: <CADex0xzfB3=aBJ7AgbTJ0hQKpmD0JSnX6xcjmu4fmqy284j5jw@mail.gmail.com>
References: <CADex0xzfB3=aBJ7AgbTJ0hQKpmD0JSnX6xcjmu4fmqy284j5jw AT mail DOT gmail DOT com>
MIME-Version: 1.0
X-IsSubscribed: yes

Greetings, Kenneth Wolcott!

>   I'm using a qx call to "net user username /DOMAIN" (probably should
> use system instead) to determine whether a person having an active
> account in an application is still an employee.

>   I get two messages back (error and/or usage) when a username is not found.

> "The user name could not be found."

> and

> "More help is available by typing NET HELPMSG 2221."

> I'd like to hide (not display, not print) these two messages.

> Coming from a UNIX/Linux background, I'd do a "2>&1 > /dev/null"
> operation to dispose of STDOUT and STDERR, but "1<&2 > NUL" (suggested
> by

> "https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true"

> does not seem to work.

That's... I don't know how to qualify this article, but it's just doesn't
quite work that way.
The semantics of redirection are same on Windows as on Linux.

net user username /DOMAIN > /dev/null 2>&1

or, under native shell (cmd)

net user username /DOMAIN > nul: 2>&1

>   I tried file descriptor 3, but that resulted in an error regarding
> unsupported file handle,. or something like that.

>   I was considering using IPC::Run3, but I don't think that will help
> with suppressing error message and usage message.

> Perhaps there is a Perl module that is native to Cygwin that will
> perform this kind of lookup for me?  Maybe a Perl module that is NOT
> native to Cygwin?

Another solution is to assign your own handles to the underlying process, but
considering you don't want the output at all, I don't see it viable.


-- 
With best regards,
Andrey Repin
Saturday, January 23, 2016 15:42:00

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019