LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   redirecting output of set -x (https://www.linuxquestions.org/questions/linux-newbie-8/redirecting-output-of-set-x-868928/)

xerox 03-16-2011 08:40 AM

redirecting output of set -x
 
I have written a script and included the command

Code:

set -x
to see what happening when i run the script.

I want to redirect the output of set -x to a file

Code:

set -x >>file.log
however the above command does not work.

Code:

exec 1>file.log
this command only redirects the output of echo commands not of set -x

Please suggest a solution to redirect the output of this command to a file.

grail 03-16-2011 08:50 AM

Try it this way:
Code:

./script > file.log 2>&1

xerox 03-17-2011 02:42 AM

I want do all this redirection from the same script...

when i tried

Code:

./script > file.log 2>&1
the system just hangs....afterwards the file.log is created...can u suggest another method...?

grail 03-17-2011 04:45 AM

I am not sure I understand what you mean? What i have given you will redirect all output into the log file.

xerox 03-17-2011 11:12 PM

I have a script read.sh in which i have the statement set -x

I want redirect the logs of read.sh to a file.log from the script read.sh itself.

The solution you suggested is working file but, once the script is run it doesnt stop, It gets stuck even though the file.log is created.

grail 03-18-2011 10:05 AM

Well that would mean there is an issue with your script. The redirection will in no way control the scripts exit abilities.
Maybe if you show the read.sh script we can see why it never stops?

xerox 03-20-2011 10:08 PM

I have decided not to redirect the output of set-x instead just redirect the error messages to an another log file. I am unable to post the script as it is related to the project i'm working for.

Thank you for your help.

grail 03-21-2011 02:03 AM

Well my only suggestion would be that you investigate anywhere you have a loop as it may well be there that it is getting stuck.

Also, if you can find a way to take out the secret stuff and show us something supposedly doing the same thing, we may be able to help diagnose the problem.

Good luck :)


All times are GMT -5. The time now is 11:02 PM.