printing to a file from dos?
Results 1 to 5 of 5

Thread: printing to a file from dos?

  1. #1
    Member
    Join Date
    Aug 2002
    Posts
    51

    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?

  2. #2
    Senior Member
    Join Date
    Oct 2001
    Posts
    786
    Code:
    netstat -n > file.txt
    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.



    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:

    Code:
    dir | more
    Which gives the output of "dir" to the "more" program/utility which prints output one screenful at a time.

  3. #3
    Member
    Join Date
    Aug 2002
    Posts
    51
    i can get the | more part to work, but i am still unable to print it to a file

  4. #4
    ********** |ceWriterguy
    Join Date
    Aug 2004
    Posts
    1,608
    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!

  5. #5
    Elite Hacker
    Join Date
    Mar 2003
    Posts
    1,407
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •