Simpler Navigation coming for Servers and Operating Systems
Coming soon: a much simpler Servers and Operating Systems section of the Community. We will combine many of the older boards, and you won't have to click through so many levels to get at the information you need. If you are looking for an older board and do not find it, check the consolidated boards, as the posts are still there.
Operating System - Microsoft
cancel
Showing results for 
Search instead for 
Did you mean: 

cmd shell and commands

SOLVED
Go to solution
Edgar Zapata
Esteemed Contributor

cmd shell and commands

Is there a tool or a command that will send the output of a command to a file?
We're running this sentence (netcat.exe):
nc -v esm9-vfpri1 515 < c:\WINDOWS\get.txt

We get this output:
DNS fwd/rev mismatch: esm9-vfpri1.vf-es.internal.vodafone.com != ESM9-VFPRI1
esm9-vfpri1.vf-es.internal.vodafone.com [10.229.28.104] 515 (printer) open

But when we try:
nc -v esm9-vfpri1 515 < c:\WINDOWS\get.txt > outputFile

the contents of outputFile is either 0 KB or 1 KB.
type outputfile returns:
ÿ

Tnks.


2 REPLIES
Sheldon Smith
Honored Contributor
Solution

Re: cmd shell and commands

Presumably the message is in the error stream and not the output stream (which you are capturing).

command 2> filename Redirect any error message into a file
(command) 2> filename Redirect any CMD.exe error into a file
command > file 2>&1 Redirect output and errors to one file
command > fileA 2> fileB Redirect output and errors to separate files

command 2>&1 >filename This will fail!

Note: While I work for Hewlett Packard Enterprise, all of my comments (whether noted or not), are my own and are not any official representation of the company.
----------
If my post was useful, click on my KUDOS! thumb below!
Edgar Zapata
Esteemed Contributor

Re: cmd shell and commands

Thanks, Sheldon.
Your response did the trick.
For some reason (still unknown to me) I was finally able to capture the output by typing this:
nc -v esm9-vfpri1 515 < c:\WINDOWS\get.txt 2> fileOutX.txt
But output doesn't show any error.

These are the contents of fileOutX.txt (which is the output I get when I simply run the command w/o redirecting anything anywhere.

DNS fwd/rev mismatch: esm9-vfpri1.vf-es.internal.vodafone.com != ESM9-VFPRI1
esm9-vfpri1.vf-es.internal.vodafone.com [10.229.28.104] 515 (printer) open

How can that be?

Tnks.