i am running script as root and trying to see if user oracle has ORACLE_HOME defined. here is my script:
su - $user << EOF 2>&1
if [ -n "${ORACLE_HOME:+x}" ]
then
echo "KO" > /tmp/oracle.tmp
else
echo "$ORACLE_HOME" > /tmp/oracle.tmp
fi
EOF
this doesnt work. it gives me if: Expression Syntax. and the file is not created. i think the problem is with the su encapsulation since when i am running the if statement alone it is working. any idea ?
And please don’t ask me why i am running as root. i know its bad practice but there is nothing i can do about it.
The code is probably not run in bash, but in sh that does not support the alternate value syntax.