Can we capture and write all the error messages which were being displayed on the command prompt screen during execution of a program into a log file?
If yes, can anyone please let me know on how to do it?
I am using ksh and working on AIX server.
Thank you in advance.
Thank you Franklin.
I understood that by writing the script as below, we can capture stdout and stderr to a file.
./program.ksh >> /home/log.txt 2>> /home/log.txt
Instead how to get the same functionality by writting something similar inside the program so that if we just run the script it should capture stderr and stdout to a file.
so now i will execute the script as
./program.ksh
and it should do the same functionality by writting the stderr and stdout to the fiile log.txt.
try this. funny what you find with a internet search.
This works for ksh but not for all other Shells. We run everything in a subshell defined by a pair of brackets.
#!/bin/ksh
(
#my commands go here
) 1>>/home/log.txt 2>>/home/log.txt