ksh echo to stderr for specific statements
I have the following shell script that echos output to the log and errors to err_file. However, I specifically want开发者_如何学Go to echo some statements to stderr. Pls help
#!/bin/ksh
echo "paramPassed: $0 $#"
err_file="error_file.txt"
new_file="new_file.txt"
exec >> ${new_file}
#exec >> ${new_file} 2>${err_file}
#exec >> ${new_file} 2>&1
if [ $# -eq 1 ]; then
username=$1
fi
userInfo=$(paramInfo ${username} | awk -F: '{print $2}')
echo ${userInfo}
rcp ${err_file} mtvst32:/rcs/ver34/${err_file}
if [ $? -ne 0 ]; then
#This doesn't work. Need the following to go to console
echo "UserInfo.SH FAILED copy to mtvst32" >> &2;
fi
I wish to send the output of the last if condition to std err however, couldn't figure out how to do.
I suspect that you're getting an error message. It would have been helpful if you posted it. However, this is likely to fix your problem:
echo "UserInfo.SH FAILED copy to mtvst32" >&2
Remove the space and one of the >
.
精彩评论