STDERR to file & terminal using tee

Hi All,
Solarix/Bash v3x

Im trying to output any standard errors created by the script to a file using the below command:
. runDTE.sh 2> "$DTE_ERROR_FILE"

however the errors do get written to the dir/file stored in $DTE_ERROR_FILE but the error does not appear on the terminal screen in STDOUT. I know I have to use the tee command and have tried it but cannot get it to work. I tried

. runDTE.sh 2> "$DTE_ERROR_FILE" | tee -a

but get bash: /: Is a directory errors... am I using this correctly?

Thanks in advance to anyone that responds.

Regards
Satnam

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

**************************************************

I would set a "tail -f" on the errlog in a second terminal window.

Or perhaps (if you don't mind the output from channel 1 going to the logfile as well):

. runDTE.sh 2>&1 | tee -a "$DTE_ERROR_FILE"

Hi,

Thanks for replying, I did try that one wit <&1 but I did not want any STDOUT going to the file, only STDERR, so I can terst if any STDERR occured within the file (ie file is non-zero and taker appropriate action.

So in summary..I want:

  1. STDERR to write to the file
  2. STDERR to also go to the terminal
  3. STDOUT NOT to go to the file.

is thare any way for this to occur?

Kind regards
Satnam

Hi.

Will this help?: 'tee' STDERR output (ksh)