Why doesn't my function go through all of it's steps?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Why doesn't my function go through all of it's steps?
# 1  
Old 03-25-2013
[Solved]Why doesn't my function go through all of it's steps?

Why doesn't the CheckJavas function go through all of it's steps?
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


Last edited by Enkouyami; 03-25-2013 at 05:30 PM.. Reason: Solved it and explained how/why
# 2  
Old 03-25-2013
Try running your script like so to see where it's stopping:

Code:
sh -x <your script>

# 3  
Old 03-25-2013
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/.

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

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Increase volume in steps

I would like to modify this so the buzzer starts at 15% and goes up to 30% in volume while it is playing. amixer -D pulse sset Master 30% > /dev/null 2>&1 cvlc --play-and-exit /usr/share/sounds/My_Sounds/Alarm-sound-buzzer.mp3 > /dev/null 2>&1 echo 'TIME IS UP.' gxmessage -fg blue... (2 Replies)
Discussion started by: drew77
2 Replies

2. Solaris

Live upgrade first steps

Hello Guys, I am a little confused about the first step in the live upgrade process. I will be glad if someone can clarify this for me. The pre-live upgrade patch, when do you add this patch to the OS you want to upgrade? 1. before creating the new boot environment? or 2. after creating... (1 Reply)
Discussion started by: cjashu
1 Replies

3. Shell Programming and Scripting

Function doesn't work

Hello, and here's my problem: I can't get my function to do what I want. When I call my function get_from_A_to_F I give it an argument $remainder. I want my function to substitute a number higher than 9 to a specific letter. If the argument is equal to 10 than it should change it to "A".... (8 Replies)
Discussion started by: linas
8 Replies

4. Shell Programming and Scripting

Why double quotation marks doesn't work in ksh function parameters passing?

I'm working on AIX 6, ksh shell. The parameters are some strings quotated by double quotation marks which from a file. They are quotated because there may be spaces in them. Example: "015607" "10" " " "A"I want to pass these parameters to a shell function by writing the following command: ... (4 Replies)
Discussion started by: Shimmey
4 Replies

5. UNIX for Dummies Questions & Answers

New install, how to capture the steps?

Hi All, I am working on a new server Dell which I need to install RH version 6.1. I need to document every thing I do on this server, how do I capture screen shot as I do the install? I used to work on Sun Solaris, I can do this by connecting on COM port after that I had the console access... (2 Replies)
Discussion started by: samnyc
2 Replies

6. Solaris

php installation steps..

hi .. i need procedure to install php on my solaris server.. i spent more than two weeks for this installation procedure.. but still couldn find a proper solution.. i have successfully enabled apache,tomcat,mysql,oracle .. this is the only issue am having rite now and its bothering me a lot.. ... (3 Replies)
Discussion started by: senkerth
3 Replies

7. Shell Programming and Scripting

First steps in Perl

Hello, I want to start learning Perl, but I need some expert's advice:) Could you recommend me any online manual or book to start with? I have some experience with bash and C, so I am not a complete newbie in programming. What's your advise to start with? Thank you very much for your answers! ... (5 Replies)
Discussion started by: tsurko
5 Replies

8. Solaris

Steps toward Solaris Administration

Dear All, I am currently working as Unix Operator. I am looking forward for Unix Solaris Administration. I need everyone's guidance on this forum, please advice me from where should i start. well i have already installed Solaris version on X86. So please let me know what should i do to become... (9 Replies)
Discussion started by: imrankhan.in
9 Replies

9. IP Networking

Subnetting in 11 steps

As seen on Digg.com, here is my ip addressing article in full... Original Subnetting in 11 Steps article Subnetting in 11 Steps There are a few things that you will need to know first. I personally use 11 rules that I learned from Mike Vana. Below you will find the 11 rules as well as... (1 Reply)
Discussion started by: jking2100
1 Replies

10. Solaris

steps to ufsrestore

Hello Folks, I have to restore from remote tape sun solaris 10. It has to have mirror raid. I have to restore /,/usr, /var,/opt, /etc,/u01. Could you please give me detailed steps to do the above? I am new to solaris Thanks Ram (1 Reply)
Discussion started by: vr76413
1 Replies
Login or Register to Ask a Question