Operating System - Microsoft
1748157 Members
4225 Online
108758 Solutions
New Discussion юеВ

Re: 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 2
Sheldon Smith
HPE Pro
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 am an HPE Employee, all of my comments (whether noted or not), are my own and are not any official representation of the company

Accept or Kudo

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.