I was trying to test nginx config in a script:
reply="$(nginx -t)"
echo $reply
But $reply is not containing the returned text. If i put first line in a terminal, nginx texts are popping in the terminal, but if i put second line in terminal, nothing outputs. My interest is to use that nginx test's output in a if statement
reply="$(nginx -t)"
if [[ ${reply} == *"nginx: configuration file /etc/nginx/nginx.conf test failed"* ]]
then
echo "It's there!";
fi
Is there any way to get the output returned by the command nginx -t in the variable ?