September 20th, 2004, 05:54 AM
printing to a file from dos?
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?
September 20th, 2004, 06:01 AM
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.
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.
September 20th, 2004, 12:43 PM
i can get the | more part to work, but i am still unable to print it to a file
September 20th, 2004, 08:15 PM
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.
Even a broken watch is correct twice a day.
Which coder said that nobody could outcode Microsoft in their own OS? Write a bit and make a fortune!
September 20th, 2004, 08:23 PM
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.