logo       

redirecting "set -x" output to a file: msg#00181

shells.bash.bugs

Subject: redirecting "set -x" output to a file

I want to do the following in a script:

----- cut -----
#!/bin/bash

exec 2>/tmp/script.debug
set -x

...
----- cut -----

but I don't want any other commands's stderr in the /tmp/script.debug file. So
somehow I need to move/duplicate file descriptors so that the current shell's
stderr goes into the /tmp/script.debug file but restores stderr to file
descriptor 2 for everything else remaining to use.

I have tried a zillion incarnations of "exec"ing fds around and cannot seem to
quite figure it out.

Thanx,
b.


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise