-1

here is what my .bat file looks like:

cd C:\cygnus\cygwin-b20\H-i586-cygwin32\bin
g++ -g hello.cpp -o hello -lm
start hello.exe 

I need the results of hello.exe written to text file. Can you help me ?

  • 2
    google ["piping"](http://www.lagmonster.org/docs/DOS7/pipes.html). FYI, at one point in computer history, if you didn't know how to do this, you were excommunicated. – SQLMason Aug 13 '13 at 16:17
  • This looks like a duplicate of http://stackoverflow.com/questions/574543/writing-all-program-output-to-a-txt-file-in-c – mars Aug 13 '13 at 16:22
  • Wow, one moment - you are running something in a cygwin folder and run it from a windows cmd.exe? Could it be that you're kind of missing the purpose of cygwin, or is that intentional? – Hulk Aug 13 '13 at 16:27
  • I forgot to add the standard, "what have you tried?" – SQLMason Aug 13 '13 at 16:35

2 Answers2

1

hello > output.txt 2>&1

will catch both standard output (1) and standard error (2) and send them to output.txt.

A quick Google search on "batch file pipe results to text file" brings you to this page.

Maple
  • 741
  • 13
  • 28
0

If you are on windows, install Cygwin, then the operation

hello > file.txt

should work (as posted in the comment)

Martin
  • 493
  • 6
  • 16