I have the below linux script(simplified):
RUN_JAVA=$(which java)
if [ -z $RUN_JAVA ]
then
echo "No Java found!" >> /tmp/output.txt
else
echo $RUN_JAVA >> /tmp/output.txt
fi
When I run it at the same host,runs perfectly,outputs to file:
/usr/java/default/bin/java
But when I run it from another host:
ssh ${user}@${hotname} "/tmp/testRemote.sh"
Then it can not find the Java installation on that host:
No Java found!
What could be the reason?