-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 ?

4
  • 2
    google "piping". FYI, at one point in computer history, if you didn't know how to do this, you were excommunicated. Commented Aug 13, 2013 at 16:17
  • This looks like a duplicate of stackoverflow.com/questions/574543/… Commented Aug 13, 2013 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? Commented Aug 13, 2013 at 16:27
  • I forgot to add the standard, "what have you tried?" Commented Aug 13, 2013 at 16:35

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

<FLAME> A quick read would let you know that this question has been resolved 4 minutes before your answer. </FLAME>
0

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

hello > file.txt 

should work (as posted in the comment)

11 Comments

-1 for turning someone's comment into your answer. Not because it's wrong... but because it's wrong for you to do that.
Also, you don't need cygwin to do that, this one of the few things cmd.exe is capable of :)
thanks, how do you display the text file on the screen after clicking on the .bat file? this can save me an extra step
on ubuntu its something like cat file.txt (to display it in cmd, if i got you right), I don't know, if that works on windows, but with cygwin it should work
Also, it seems that cygwin is already installed, note the path in the first line ;)
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.