Printing output to the monitor

Hi!,

In my shell scripts, I always create a logfile by adding the following line in the beginning:

exec >file.log 2>&1

This in turn directs all the output to this logfile till the script executes.

But now, I have to write some output to the monitor for the users.

So, i am doing it by the following method:

CUR_DEVICE=`tty`
echo "Whatever to be outputed" >$CUR_DEVICE

This works for me.. But is there any better way than this??

You can write to the current terminal using /dev/tty

e.g: echo "message" >/dev/tty

You could even open a new file descriptor.

e.g: in ksh:

exec >file.log 2>&1 3>/dev/tty
:
print -u3 "message"

Thanks.. That works great....