Results 1 to 6 of 6
Hello, everyone,
I am writing a console program in Linux. It is necessary for this program to kill the terminal after every run. However, I would like to have the ...
- 01-27-2009 #1Just Joined!
- Join Date
- Jan 2009
- Posts
- 3
save the terminal screen
Hello, everyone,
I am writing a console program in Linux. It is necessary for this program to kill the terminal after every run. However, I would like to have the message on the terminal recorded in a file (only the information just before the end of the program is needed).
How can I do that with some bash command, or program code (I use C)?
Thank you in advance.
Sincerely yours
Ming
- 01-27-2009 #2
Well, there are two options.
The simplest one would be to just output the necessary information at the end of the program to a file instead of to the terminal. This is fairly trivial.
A slightly more complex way would be to launch the program as follows:
The "tee" program writes all input to both stdout and each file that it is given. Therefore, this approach would duplicate all of the program's output to the terminal and to the file "program_log".Code:my_program | tee program_log
DISTRO=Arch
Registered Linux User #388732
- 01-27-2009 #3Just Joined!
- Join Date
- Jan 2009
- Posts
- 3
Thank you Cabhan.
Your recommendations are really helpful. However, my problem is a little tricky here.
I made my program to autostart after booting using
Exec = xfc4-terminal --working-directory = /path/to/file ./file
When the program is ended unexpectedly, the terminal is ended with it, and I lost all the debug information on the screen. Because there are quite a lot of output and debug information, a log file for all of them is not a practical option since I do not have space to save it. Unfortunately, I do not know where the problem is, so I can not decide where the program will end.
Above is the reason that I am looking for a solution to just record the output of the program just before the termination of the program.
Sincerely yours
Ming
- 01-27-2009 #4
If something abnormal is happening in the execution, why do you autorun it? Just launch the terminal, and run the program yourself. Comment out whatever portion of the code tries to kill the terminal, and check for the problem that way.
DISTRO=Arch
Registered Linux User #388732
- 01-27-2009 #5Just Joined!
- Join Date
- Jan 2009
- Posts
- 3
Thank you for the input.
About one thing you are definitely right, I need to do more debugging.
Thank you again.
Sincerely yours
Ming
- 01-28-2009 #6
In complex scripts that may or may not work but have to run unattended, I let it output debugging info from within the script itself.
--or--Code:for i in list ; do complex stuff && echo "it worked" >> /path/to/debuglog || echo "it didnt work" >> /path/to/debuglog done
Code:if [ test $VAR ] ; then # test nr 1 echo "test nr 1 passed, var is $VAR" >> /path/to/debuglog if [ test ] ; then # test nr 2 echo "test nr 2 passed, var is $VAR" >> /path/to/debuglog else echo "test 1 and 2 failed, var is $VAR" >> /path/to/debuglog fiCan't tell an OS by it's GUI


Reply With Quote