Register
It is currently Fri Jul 25, 2014 12:44 am

[Solved]Why doesn't my function complete all of it's steps?


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Mon Mar 25, 2013 11:08 am   

Joined: Mon Mar 25, 2013 10:57 am
Posts: 1
Why doesn't the CheckJavas function go through all of it's steps? It stops after it displays if OpenJDK 6 is installed or not, doesn't go through the Java 7 and displaying the java folders found, and then skips on to ls /usr/lib/jvm/.

Code:
#-------------------#
#   Java Checking   #
#-------------------#
CheckJavas() { # Here, this script will attempt to check for Java by checking to see if installation folders are present.
echo -n "Checking for Java"
echo ""
echo "Looking for Sun Java 6"
if [ -e /usr/lib/jvm/java-6-sun ] && [ -e /usr/lib/jvm/java-6-sun/bin ] && [ -e /usr/lib/jvm/java-6-sun/bin/java ]; then
    echo "Sun Java 6 is installed!"
    echo ""
else
    echo "Sun Java 6 is NOT installed"
    echo ""
fi
echo -n "Looking for Oracle Java 7"
if [ -e /usr/lib/jvm/java-7-oracle ] && [ -e /usr/lib/jvm/java-7-oracle/bin ] && [ -e /usr/lib/jvm/java-7-oracle/bin/java ]; then
    echo "Oracle Java 7 is installed"
    echo ""
else
    echo "Oracle Java 7 is NOT installed"
    echo ""
fi
echo -n "Looking for OpenJDK 6"
if [ -e /usr/lib/jvm/java-6-openjdk-common ] && [ -e /usr/lib/jvm/java-6-openjdk-common/jre ] && [ -e /usr/lib/jvm/java-6-openjdk-common/jre/lib ]; then
    echo "OpenJDK 6 is installed"
    echo ""
else
    echo "OpenJDK 7 is NOT installed"
    echo ""
fi
echo -n "Looking for OpenJDK 7"
if [ -e /usr/lib/jvm/java-7-openjdk-common ] && [ -e /usr/lib/jvm/java-7-openjdk-common/jre ] && [ -e /usr/lib/jvm/java-7-openjdk-common/jre/lib ]; then
    echo "OpenJDK 7 is installed"
    echo ""
else
    echo "OpenJDK 7 is NOT installed"
    echo ""
fi
echo "Detected java folders:"
echo "Default java client detected:"
java -version
echo ""
ls /usr/lib/jvm/
} ## END CheckJavas
CheckJavas


In in full script, those problems existed. When I cut the script into just the faulty function and ran it, the Detected java folders output came after the Default java client detected. I fixed that then pasted in back into my script and everything works. Here is what I should have done:
Code:
#-------------------#
#   Java Checking   #
#-------------------#
CheckJavas() { # Here, this script will attempt to check for Java by checking to see if installation folders are present.
echo "Checking for Java"
echo ""
echo "Looking for Sun Java 6"
if [ -e /usr/lib/jvm/java-6-sun ] && [ -e /usr/lib/jvm/java-6-sun/bin ] && [ -e /usr/lib/jvm/java-6-sun/bin/java ]
then
    echo "Sun Java 6 is installed!"
    echo ""
else
    echo "Sun Java 6 is NOT installed"
    echo ""
fi
echo -n "Looking for Oracle Java 7"
if [ -e /usr/lib/jvm/java-7-oracle ] && [ -e /usr/lib/jvm/java-7-oracle/bin ] && [ -e /usr/lib/jvm/java-7-oracle/bin/java ]
then
    echo "Oracle Java 7 is installed"
    echo ""
else
    echo "Oracle Java 7 is NOT installed"
    echo ""
fi
echo -n "Looking for OpenJDK 6"
if [ -e /usr/lib/jvm/java-6-openjdk-common ] && [ -e /usr/lib/jvm/java-6-openjdk-common/jre ] && [ -e /usr/lib/jvm/java-6-openjdk-common/jre/lib ]
then
    echo "OpenJDK 6 is installed"
    echo ""
else
    echo "OpenJDK 7 is NOT installed"
    echo ""
fi
echo -n "Looking for OpenJDK 7"
if [ -e /usr/lib/jvm/java-7-openjdk-common ] && [ -e /usr/lib/jvm/java-7-openjdk-common/jre ] && [ -e /usr/lib/jvm/java-7-openjdk-common/jre/lib ]
then
    echo "OpenJDK 7 is installed"
    echo ""
else
    echo "OpenJDK 7 is NOT installed"
    echo ""
fi
echo "Detected java folders:"
ls /usr/lib/jvm/
echo ""
echo "Default java client detected:"
java -version
} ## END CheckJavas
CheckJavas


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP