SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Redhat since 5.2, Slackware since 9.0, Vector since 4.0
Posts: 209
Rep:
Script works on Redhat but not on Slack
Dear all.
I'm moving from Redhat to slackware.
I have several scripts that were working on Redhat but are not working on Slackware.
Please help.
1. /etc/profile.d/setjava.sh
----------------------------
# This script call Java initialisation script
# if the user is member of java group
#--------------------------------------------
### THIS if LINE IS NOT WORKING ON SLACK
### Telling something about unary operator expected
if [ `id -n -G | grep java` ]; then
source /java/bin/setjava.sh
echo "Java is ready at $JAVA_HOME"
fi
2. /etc/rc.d/init.d/jetty.sh
-----------------------
#!/bin/sh
#
# chkconfig: 345 80 20
# description: jetty
# processname: jetty
#
# This script is installed at /etc/rc.d/init.d/
# Part of sysvinit on redhat.
# Called directly from /etc/rc.d/rc.local on slackware
# source /etc/rc.d/init.d/jetty.sh start
# -----------------------------------------------------
# Hapus $JETTY_PID jika tidak sah
if [ -f $JETTY_PID ]; then
PID=`cat $JETTY_PID`
RUNNING=`ps -p $PID | grep $PID`
if ! [ "$RUNNING" ]; then
rm $JETTY_PID
fi
fi
cd $JETTY_HOME
### IT IS NOT WORKING HERE.
### The initialisation stop into a shell.
### I had to type exit or press Ctlr-C to continue the boot process
su -m -s "/bin/sh" -c "$JETTY_HOME/bin/jetty.sh $1 $CONFIGS" $USER
3. jetty.sh
--------------------------
This is the original jetty.sh from jetty distribution.
I called it directly, and it said: "unary operator expected at line 429".
Here is the line
JAVA_VERSION=`expr "$($JAVA -version 2>&1 | head -1)" : '.*1\.\([0-9]\)'`
#####################################################
# Build the classpath with Jetty's bundled libraries.
#####################################################
### LINE 429
if [ $JAVA_VERSION -lt 4 ]
then
CP=$(ls $JETTY_HOME/ext/*.jar $JETTY_HOME/lib/*.jar | \
egrep -v org.mortbay.jetty.jar | \
paste -s -d"$PATH_SEPARATOR" - )
else
CP=$(ls $JETTY_HOME/ext/*.jar $JETTY_HOME/lib/*.jar | \
egrep -v org.mortbay.jetty-jdk1.2.jar\|crimson.jar\|javax.xml.jaxp.jar | \
paste -s -d"$PATH_SEPARATOR" - )
fi
Distribution: Redhat since 5.2, Slackware since 9.0, Vector since 4.0
Posts: 209
Original Poster
Rep:
Nothing wrong with the path. I have properly customized it.
But the problem is with the command. See again
1.-------------------
if [ `id -n -G | grep java` ]; then ## PROBLEM HERE
source /java/bin/setjava.sh
echo "Java is ready at $JAVA_HOME"
fi
If I run this command with a certain user (with 3 groups)
$ id -n -G | grep java
users java share
See that it prints 3 groups.
But inside the script, it raises the error.
All I wanna do is to check if the string is empty,
then the user is not a member of java group.
2.----------------
su -m -s "/bin/sh" -c "$JETTY_HOME/bin/jetty.sh $1 $CONFIGS" $USER
I want to run jetty as user $USER, not as root.
This command should:
* change user to $USER
* launch a shell (bin/sh)
* execute the script (jetty.sh)
But it does not. It only launches the shell then stops there waiting.
3. -------
if [ $JAVA_VERSION -lt 4 ]
....
fi
This should be simple.
if JAVA_VERSION less than 4 then do something.
What is the comparison operator on slackware ?
I wonder what is the difference between /bin/sh on slackware and /bin/sh on redhat ?
Distribution: Redhat since 5.2, Slackware since 9.0, Vector since 4.0
Posts: 209
Original Poster
Rep:
Dear all.
I found the problem.
1.-------------------
Corrected to:
GROUP=`id -n -G | grep java`
if [ "$GROUP" ]; then ## NO PROBLEM ANYMORE
source /java/bin/setjava.sh
echo "Java is ready at $JAVA_HOME"
fi
2&3
-----
The culprit is the Java. In Redhat I was using Sun JDK, but IBM JDK in Slack.
To call the java, I have setup environment variable:
JAVA="/opt/java/java -server"
It works for Sun but not for the IBM, so the script does not work.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.