0

I want to copy the output in cmd prompt to txt file. I used the following command:

sample.exe /all > sample.txt

But the above command shows only the printf statements not showing the scanf. So i moved to tee command. Can anyone provide me the command to save the output file for sample.exe in txt file

Balaji Kondalrayal
  • 1,743
  • 3
  • 19
  • 38

2 Answers2

0

If I understood correctly, you want not only the output of your program to show up in a log, but also the input.

In this case the simplest way to go would be to have your program echo its input:

2014-03-17 15:18
User "Foo" called "sample.exe foo bar 42".
Please enter your phone number:
User input: "555 1234 999"
Processing "foo bar 42"...

You get the idea. If input is important, print it to terminal. If that makes your program chatty, only print it if the -v or --verbose command line option is given.

DevSolar
  • 67,862
  • 21
  • 134
  • 209
  • @Balaji: OK, seems your problem is not with logging input, your problem is basic programming... that's something you need a book or a good tutorial for, not a Q&A website like this one... – DevSolar Mar 17 '14 at 14:24
0

The question is not entirely clear, so I'm making some guesses here. I believe you are saying that the command sample.exe is reading input which you are generally providing interactively (ie, you type it into the same terminal from which the command was executed.) In that case, it is not merely the output of the program that you want to save in the file, but the input as well, and you probably want that interleaved with the output in the same order that you see it when you invoke the program. In that case, pmg's comment is accurate, and you want the script command. If you have script just do:

$ script sample.txt     # start a new shell, saving to sample.txt
$ sample.exe /all
$ exit                  # close the shell
William Pursell
  • 204,365
  • 48
  • 270
  • 300