Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am facing a slight problem in my project. I have a menu driven program and one of my options is Display all, which displays all the entries from a map using a loop. The display is on the terminal and I am not being able to view all the entries because it only shows the last few entries before my prompt comes again. I want the output to be redirected to a file so that I can use more commands and give the user a view accordingly. Please suggest few commands or code.

share|improve this question
    
When you say "menu driven" what do you mean? Is this a console or graphical program? What command do you use to launch the program? Does it have input/output arguments? –  Caleb Jun 15 '11 at 11:04
add comment

3 Answers

You can set up a pipeline when you launch your program to write its output to a file.

$ your_program > /tmp/output.txt

If the program does other things with the output, such as prompt the user for input, it is likely that it uses the second output channel (the error channel) to show menus, so it is possible that this won't get in the way of normal operation and will only capture dump output.

Additionally, programs such as GNU screen and tmux come in very handy for this by allowing you to capture and look at the scroll back history from a window and even capture parts of it and log it to a file.

If that doesn't work, tell us more about your program and usage.

share|improve this answer
    
it is console based and i use default ./a.out to execute my program. 1..... 2..... 3.Display –  newars Jun 15 '11 at 12:07
    
Does redirecting as above do the job? What else does your program output? If you wrote the program did you setup interface output on stderr and data output on stdout? –  Caleb Jun 15 '11 at 12:31
add comment

You can redirect terminal output to a file using this syntax:

program params > fileName
share|improve this answer
add comment

Standard output (stdout):

command > file

or if you want to append:

command >> file

Standard error (stderr):

command 2> file

or if you want to append:

command 2>> file
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.