LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-17-2003, 04:41 AM   #1
Kocil
Member
 
Registered: Feb 2003
Distribution: Redhat since 5.2, Slackware since 9.0, Vector since 4.0
Posts: 209

Rep: Reputation: 31
Unhappy 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
# -----------------------------------------------------

CONFIGS="jetty4.xml"
USER="java"

# Setting Jetty
# Lihat $JETTY_HOME/bin/jetty.sh
JETTY_HOME="/java/server/jetty"
JETTY_RUN="/var/jetty"
JETTY_CONSOLE="$JETTY_RUN/console.txt"
JETTY_PID="$JETTY_RUN/jetty.pid"
JETTY_LOG="$JETTY_RUN/"

# Setting Java
JAVA_HOME=/usr/java/j2sdk
JAVA="$JAVA_HOME/bin/java -server"
JAVA_OPTS=""

export JAVA_HOME JAVA JAVA_OPTS
export JETTY_HOME JETTY_CONSOLE JETTY_RUN JETTY_PID

# 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
 
Old 07-17-2003, 09:59 AM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Well, you want to make sure all the path's are correct in your script, as they may differ from Redhat and Slackware most likely.

One I can see clearly is:

2. /etc/rc.d/init.d/jetty.sh

Slackware doesn't have a /etc/rc.d/init.d directory but is totally different with just a /etc/rc.d directory.. and so on..

You'll most likely need to customize the script for Slack to work.
 
Old 07-17-2003, 11:21 PM   #3
Kocil
Member
 
Registered: Feb 2003
Distribution: Redhat since 5.2, Slackware since 9.0, Vector since 4.0
Posts: 209

Original Poster
Rep: Reputation: 31
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 ?
 
Old 07-18-2003, 12:03 PM   #4
Kocil
Member
 
Registered: Feb 2003
Distribution: Redhat since 5.2, Slackware since 9.0, Vector since 4.0
Posts: 209

Original Poster
Rep: Reputation: 31
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.


Sorry for the trouble.

Cheers.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cronjob not working but script works dtra Linux - Newbie 4 02-28-2005 05:05 PM
Orinoco, Slack 10, It works! ..now and then... noxious Linux - Wireless Networking 0 09-29-2004 09:29 PM
Shell script works on RH 7.2 but not on RH ES brian Red Hat 1 08-31-2004 11:55 AM
A C-shell script doesn't work on redhat 7.3 but works on Sun Solaris Belmer Linux - Newbie 2 02-08-2004 11:05 AM
Only test.cgi script works? lonny Programming 1 12-09-2003 08:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration