I have an application that logs a lot of noise to stderr and REALLY slows down the execution of the application. I would like to redirect that output to null. Is this possible with cmd.exe?
How to redirect stderr to null in cmd.exe [closed]
Asked Answered
Your DOS command 2> nul
Read page Using command redirection operators. Besides the "2>" construct mentioned by Tanuki Software, it lists some other useful combinations.
However following will do almost the opposite of what some may expect
copy foo.txt con >> bar 2>nul
. bar will contain the text one file(s) copied and the console will containt the content of foo.txt. –
Unweave Note that this method outputs a blank line, which might cause problems for some scripts. I am still trying to find a way to suppress that. –
Sidnee
@Sidnee I don't think it does. It's probably something specific to your usage scenario. Case in point:
@for /L %C in (1,1,10) do @type nonexistent 2> nul
does not produce ten blank lines. –
Dorolice @PatrickFromberg That's because
con
is not a synonym for STDOUT; it's a pseudofile associated with actual console, so it's not affected by redirection. Somewhat akin to Linuxish (cat /proc/version > /dev/tty) > bar
: the outer redirect won't affect the inner one. –
Dorolice If I give
non exitsant command
or soem random umjumflunge
and redirect to nul
, I still get a blank lien at the DOD prompt –
Sidnee @Sidnee That's just the interactive cmd behavior which won't affect scripting. It simply adds a blank line after each interactive command it executes, I/O redirection or not. Try: pastebin.com/JMeA6Mti –
Dorolice
I think there is a problem in the accepted answer. It should be 2>&1> nul You are only redirecting stderr; not stdout, as in
gswin64c --help 2>&1> nul
–
Edgeworth @SamHabiel Not really. The question is about
stderr
. –
Dorolice Referenced page is here: technet.microsoft.com/en-us/library/bb490982.aspx –
Ermelindaermengarde
DOS commands aren't supported any more are they? A win console command, yes. –
Kunin
I always forget it's one
l
then end up creating a file called null
and get unreasonably pissed off –
Sway © 2022 - 2024 — McMap. All rights reserved.
@command > nul 2>&1
– Mandrake