Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6705797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:26:44+00:00 2026-05-26T07:26:44+00:00

Please can someone identify what is the problem in my shell script, it works

  • 0

Please can someone identify what is the problem in my shell script, it works fine on other Linux systems except on Sunos below is my output

drifter% cat run.sh
#!/bin/sh -x
if [ ! $JAVA_HOME ] || [ $JAVA_HOME == "" ]
then
    echo Enter path to JAVA HOME:
    read JAVA_HOME
fi

if [ ! -f $JAVA_HOME/bin/java ]
then
echo "JAVA_HOME variable does not point to a valid java instance"
exit 1
fi

echo "Using JAVA_HOME: "$JAVA_HOME
JAVA_BIN=$JAVA_HOME/bin
ver=`$JAVA_HOME/bin/java -version 2>&1 | head -1 | awk '{print $NF}' | cut -d'.' -f2`

if [ $ver -ge 5 ]
then
    JAVA_LIB=`pwd`/lib
    export JAVA_LIB

    $JAVA_BIN/java -cp ./lib/a-jdbc-sqlserver-4.2.1.jar:./lib/a-jdbc-db2-4.2.1.jar:./lib/ilmInit.jar:./lib/db2jcc.jar:./lib/db2jcc_license_cisuz.jar:./lib/db2jcc_license_cu.jar:./lib/csm-runtime-1.0.jar:./lib/csm-dbutil-1.0.jar:./lib/classes12_g.jar:./lib/commons-beanutils-1.8.3.jar:./lib/commons-cli-1.2.jar:./lib/commons-exec-1.1.jar:./lib/log4j-1.2.8.jar:./lib/groovy-all-1.8.1.jar -Dlog4j.configuration=com/a/csm/log4j.xml -Dendorsed_plugins_dir=./plugins InitValues $@

else
    echo Current JDK $ver
    echo "Expected JDK 1.5 or later. Please fix your JAVA HOME and try again."
    exit 1
fi
drifter% ./run.sh
+ [ ! ]
./run.sh: test: argument expected
drifter%

Note: I am using csh

Update

I changed "$JAVA_HOME" everywhere

but still i get

drifter% ./run.sh
+ [ ! /home/ilma1/java16/java ]
+ [ /home/ilma1/java16/java ==  ]
./run.sh: test: unknown operator ==
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:26:44+00:00Added an answer on May 26, 2026 at 7:26 am

    Probably $JAVA_HOME isn’t set. An unset variable normally expands to an empty string, so this:

    if [ ! $JAVA_HOME ] || [ $JAVA_HOME == "" ]
    

    is equivalent to this:

    if [ ! ] || [ == "" ]
    

    which is a syntax error. ([ is another name for the test command; it’s usually a symbolic link.)

    Try quoting the variable name:

    if [ "$JAVA_HOME" == "" ]
    

    And if you set $JAVA_HOME in response to the prompt, you probably want to export it. (Actually I’m not sure of that; does java depend on $JAVA_HOME being set?)

    EDIT:

    Ok, it looks like $JAVA_HOME was set.

    For the test (or [) command, the string equality operator is =, not ==.

    Try:

    if [ "$JAVA_HOME" = "" ]
    

    EDIT2:

    This:

    if [ -z "$JAVA_HOME" ]
    

    is probably better (see @n.m’s answer).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please identify the functional/performance differences, if any, between SET and SELECT in
Can someone please explain the structure of this line of a script for me?
can someone please identify what type of view this is, as i want to
Please can someone help sort a noob out? I've posted this problem on various
Please can someone help? I have the following code which uploads a file to
In WPF: Can someone please explain the relationship between DependencyProperty and Databinding? I have
Can someone please point me to the easiest way to have a timer in
Can someone please point me to articles or books that discusses different programming paradigm
Can someone please derive a concrete example from the following: http://www.urdalen.com/blog/?p=210 ..that shows how
Can someone please let me know how to get the different segments of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.