Error file Redirection

Hello All,

I was wondering is there any other way in Shell Scripting to redirect the errors to a output file inside a shell script with using a error status checking or a command line redirection.

Say without doing this

ksh test.ksh 2> error.txt

or without doing this ...

if [ "$?" = "1" ]; then
exit 1
fi

Thanks

Rahul

Your question is not very clear, but my hunch is you might be looking for this.

exec 2>error.txt

I don't understand the status checking part, though. Is that a different question?

My Question is If we need to redirect the error output to a text file in shell script

we can do by using this ksh test.ksh 2> errorfile.txt
or We can do a Exit Status check as below ..

if [ "$?" = "1" ]; then
...
fi

But What my doubt is there any other way to redirect the the errors to the error file rather than using the command line redirection to a text file. I want to handling the error redirecting part within the shell script.

Thanks in advance

Rahul

That's precisely what the exec does. I still don't understand the exit status check part.