Click to See Complete Forum and Search --> : Korn Shell scripting issue


developerforpeace
February 18th, 2005, 07:15 PM
Hi All,

I wrote a small shell script which is giving me problems. Please help.

exec 1> abc.txt
while read input
do
print "$input"
done < hello.txt
exec 1>&-

Here the stdout file descriptor is associated with the file
abc.txt. thereby causing the stdout to be redirected to
the file abc.txt. The problem here
is that after the script executes, the stdout is permenantly
associated with the file abc.txt . So if I type the command
ls on the command prompt I cannot see it on the screen
because the output goes to the file abc.txt. I cannot even
vi the file abc.txt because it is being displayed else.
Question for me is how to disassociate the stdout from abc.txt and
make the stdout work the normally once I finish executing the script.
Also, how do this within the script itself. I thought it was normal to
redirect stdout to some file.


Thank you

Developer for peace