JSI Tip 2996. How do I prevent a command from displaying any output, including any error message?


I first introduced the topic of piping commands and their output in tips 0501 and 0823.

If you issue a Net USE Z: when Z: is mapped, you receive a display similar to:

Local name        Z:
Remote name       \\ServerName\ShareName
Resource type     Disk
Status            OK
# Opens           0
# Connections     9
The command completed successfully.
If you issue a net use Z: >Nul when Z: is mapped, nothing is displayed.

When you issue a Net USE Z: when Z: is NOT mapped, you receive:

The network connection could not be found.

More help is available by typing NET HELPMSG 2250.
When you issue a net use Z: >Nul when Z: is NOT mapped, you receive:
The network connection could not be found.

More help is available by typing NET HELPMSG 2250.
To prevent output on both Stdout and Stderr, issue net use Z: 1>Nul 2>&1 and nothing will be displayed.

NOTE: There are two options:

      1> pipes Stdout

      2> pipes Stderr

      >  defaults to 1>.


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish