Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a c++ code got started by a shell script. The shell script has the following line to start the c++ code /home/user/test_client/a.out Now i want to capture the output of this code in a file called message.log What is the right way to do this ? I have tried /home/user/test_client/a.out >> message.log It doesn't work. Am I doing anything wrong here ?

share|improve this question
    
"It doesn't work" is not a helpful description of the problem. Did you get an error? –  David Schwartz Jun 22 '12 at 3:07
    
@David Schwartz: Sorry about that. I am not getting error. The message.log file is created and its empty. and the a,out is running as well.. –  Deepak Jun 22 '12 at 3:11
add comment

2 Answers 2

up vote 4 down vote accepted

Try a.out >> message.log 2>&1

That will also redirect stderr, which is probably where the messages are going.

share|improve this answer
    
Okay i will try that.. Actually the log file i am creating is inside /var/log/message.log so is there any problem with that ? –  Deepak Jun 22 '12 at 3:04
    
Are you running it as root? Typically users cant write to /var/log/message.log. Try writting it to your home directory instead. –  Grant Jun 22 '12 at 3:11
    
I got it sorted.. There is no output from the a.out at this stage.. It will output only in case of some errors. So thanks for that!! 2>&1 helped me in this case... –  Deepak Jun 22 '12 at 3:17
add comment

Please use the syslog API for write to /var/log/messages

http://linux.die.net/man/3/syslog

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.