is it possible to print the results from a dos command to a file? ie print the results to to netstat -n to a word pad file?
Printable View
is it possible to print the results from a dos command to a file? ie print the results to to netstat -n to a word pad file?
The ">" character redirects output into the file "file.txt". "file.txt" is a plain-text file that has all of the output from whatever was piped into it, in this case, "netstat -n". It is something done by the Command Prompt, and isn't program dependant. IE, "dir > file.txt" works too.Code:netstat -n > file.txt
Command Prompt / DOS also has other things, like "|" or Pipe, which can give the output to another program's input. A common use of it is:
Which gives the output of "dir" to the "more" program/utility which prints output one screenful at a time.Code:dir | more
i can get the | more part to work, but i am still unable to print it to a file
netstat -n | file.txt should work. if for whatever reason it tells you 'file.txt' doesn't exist, use copy con and create it empty, then re run the command. Hope that helps.
Everything Tim_Axe said should have worked.
What command were you using that you are trying to get the output to go to a file, and how did you run it?
I believe |3lack|ce's example will give you the error "file.txt: command not found"
What you said to do will take the output of netstat -n and use it as input for file.txt which it thinks is a command from that syntax. Since it's not you get the error command not found. Just try what Tim_Axe said, and if it doesn't work post exactly how you tried it, and we'll try and explain why.