public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Using Perl on Cygwin; how to prevent display of unwanted usage/error message?
@ 2016-01-23 12:59 Kenneth Wolcott
  2016-01-23 13:05 ` Erik Soderquist
  2016-01-23 15:21 ` Andrey Repin
  0 siblings, 2 replies; 4+ messages in thread
From: Kenneth Wolcott @ 2016-01-23 12:59 UTC (permalink / raw)
  To: cygwin

Hi;

  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.

  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?

Thanks,
Ken Wolcott

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using Perl on Cygwin; how to prevent display of unwanted usage/error message?
  2016-01-23 12:59 Using Perl on Cygwin; how to prevent display of unwanted usage/error message? Kenneth Wolcott
@ 2016-01-23 13:05 ` Erik Soderquist
  2016-01-23 14:25   ` Kenneth Wolcott
  2016-01-23 15:21 ` Andrey Repin
  1 sibling, 1 reply; 4+ messages in thread
From: Erik Soderquist @ 2016-01-23 13:05 UTC (permalink / raw)
  To: cygwin

In cygwin, I use >/dev/null 2>&1 quite frequently and it works as expected.

In windows cmd.exe, I don't know why they would recommend the < part
for dealing with output, but I have used >NUL 2>&1 for the same effect
in Windows command shells.

-- Erik

On Fri, Jan 22, 2016 at 6:21 PM, Kenneth Wolcott
<kennethwolcott@gmail.com> wrote:
> Hi;
>
>   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.
>
>   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?
>
> Thanks,
> Ken Wolcott
>
> --
> 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
>

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using Perl on Cygwin; how to prevent display of unwanted usage/error message?
  2016-01-23 13:05 ` Erik Soderquist
@ 2016-01-23 14:25   ` Kenneth Wolcott
  0 siblings, 0 replies; 4+ messages in thread
From: Kenneth Wolcott @ 2016-01-23 14:25 UTC (permalink / raw)
  To: cygwin

> On Fri, Jan 22, 2016 at 6:21 PM, Kenneth Wolcott
> <kennethwolcott@gmail.com> wrote:
>> Hi;
>>
>>   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.
>>
>>   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?
>>
>> Thanks,
>> Ken Wolcott
>>

On Fri, Jan 22, 2016 at 3:34 PM, Erik Soderquist
<ErikSoderquist@gmail.com> wrote:
> In cygwin, I use >/dev/null 2>&1 quite frequently and it works as expected.
>
> In windows cmd.exe, I don't know why they would recommend the < part
> for dealing with output, but I have used >NUL 2>&1 for the same effect
> in Windows command shells.
>
> -- Erik

Hi Erik;

  Thank you!  ">/dev/null 2>&1" solved the problem of hiding the
information I did not want displayed.

Thanks,
Ken

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using Perl on Cygwin; how to prevent display of unwanted usage/error message?
  2016-01-23 12:59 Using Perl on Cygwin; how to prevent display of unwanted usage/error message? Kenneth Wolcott
  2016-01-23 13:05 ` Erik Soderquist
@ 2016-01-23 15:21 ` Andrey Repin
  1 sibling, 0 replies; 4+ messages in thread
From: Andrey Repin @ 2016-01-23 15:21 UTC (permalink / raw)
  To: Kenneth Wolcott, cygwin

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-23 13:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-23 12:59 Using Perl on Cygwin; how to prevent display of unwanted usage/error message? Kenneth Wolcott
2016-01-23 13:05 ` Erik Soderquist
2016-01-23 14:25   ` Kenneth Wolcott
2016-01-23 15:21 ` Andrey Repin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).