exec comand

hi,

i have written a small script in which i use exec command and redriect output to a file..after sometime i want to switch it off and redirect the output to screen..how to do it

exec >> /tmp/out.txt 2>&1

//set of statements

then i want to switch of these exec as the rest should get displayed in screen and not int out.txt file

Try this:
exec 4>&1 >> script.out 5>&2 2>&1
exec 1>&4 4>&- 2>&5 5>&-

is it possible for u to tell me wat this implies

The first line sends fd 1 and fd 2 into your file. After that first line, put the lines that need to output to your file. Then use my second line which restores fd 1 and fd 2 to what they were originally.

The first line saves fd 1 and 2 by copying then to fd 4 and 5. The second line copies them back. The construct "4>&-" closes fd 4.

Still bounced, :eek:

Very kind of you if you can give me a link. :stuck_out_tongue:

Go through chapter 24 and 25 of this link.

Check out this article one as well.

Explains the use of fd's extensively.

vino