I am running tcsh/csh shell on my machine. lately i have realized my stderr file redirection is not working.
Please find the terminal logs as below:
>echo b c >>& log
>cat log
b c
>echo $a b c >>& log
a: Undefined variable.
>cat log
b c
I have never faced such issues, hence not sure how to debug or troubleshoot. Please advice!
try setting some values to the variable a , like
set a = 12
then echo $a b c
@codemaniac
I understand that, but thats not my intention. i want to redirect the stderr into a file.
Can you try the line:
>echo $a b c >>& log
in your unix terminal(tcsh) and see if it fails.
As suggested by guru ,
try something like
( echo $a b c > /dev/stdin ) > & log
An alterate method of redirection is using tee. While I use >& or >>& , i am altogether blocking any output to be displayed on terminal. Is there a way I can do both, that is: for each statement
a) direct stdout+stderr to a file.
b) display stdout+stderr on terminal
I need to confirm if i can use something like this(below) to meet my requirements
>csh ./script_name | tee -a log
In my case it only directs stdout to log file and blocks stderr.