hi,

can i run a shell script as a daemon ?

the shell script looks like this :

#!/bin/sh

BATDIR='/'
export JAVA_HOME='/usr/java/jdk1.5.0_06/bin/java'
export MESSAGE_SENDER_HOME='/home/mas50o21/MessageReader/'
export LIB='/lib/'
export COMMONS='/commons/'
export JBOSS_HOME='/home/jboss/jboss-4.0.3SP1/'

export CLASSPATH=$CLASSPATH:${JBOSS_HOME}client/jboss-common-client.jar: \
${JBOSS_HOME}client/namespace.jar:${JBOSS_HOME}client/jboss-system-client.jar: \
${JBOSS_HOME}client/getopt.jar:${JBOSS_HOME}client/log4j.jar: \
${JBOSS_HOME}client/activation.jar:${JBOSS_HOME}client/jboss-jaxrpc.jar: \
${JBOSS_HOME}client/mail.jar:${JBOSS_HOME}client/jboss-saaj.jar: \
${JBOSS_HOME}client/jboss-j2ee.jar:${JBOSS_HOME}client/jboss-transaction-client.jar: \
${JBOSS_HOME}client/jmx-invoker-adapator-client.jar:${JBOSS_HOME}client/concurrent.jar: \
${JBOSS_HOME}client/jboss-deployment.jar:${JBOSS_HOME}client/jbossx-client.jar: \
${JBOSS_HOME}client/jbossmq-client.jar: \
${JBOSS_HOME}client/jbosscx-client.jar:${JBOSS_HOME}client/commons-logging.jar: \
${JBOSS_HOME}client/axis-ws4ee.jar:${JBOSS_HOME}client/wsd14j.jar: \
${JBOSS_HOME}client/commons-discovery.jar:${JBOSS_HOME}client/jboss-ws4ee-client.jar: \
${JBOSS_HOME}client/jbossha-client.jar:${JBOSS_HOME}client/scout.jar: \
${JBOSS_HOME}client/jboss-juddiaxis.jar:${JBOSS_HOME}client/jbossjmx-ant.jar: \
${JBOSS_HOME}client/jboss-iiop-client.jar:${JBOSS_HOME}client/avalon-framework.jar: \
${JBOSS_HOME}client/logkit.jar:${JBOSS_HOME}client/jacorb.jar: \
${JBOSS_HOME}client/jboss-jsr77-client.jar:${JBOSS_HOME}client/jbossall-client.jar: \
${JBOSS_HOME}server/mobi/lib/jnpserver.jar:${JBOSS_HOME}server/mobi/lib/activation.jar: \
${JBOSS_HOME}server/mobi/lib/bsh-deployer.jar:${JBOSS_HOME}server/mobi/lib/jboss-transaction.jar: \
${JBOSS_HOME}server/mobi/lib/jbossmq.jar:${JBOSS_HOME}server/mobi/lib/jboss-common-jdbc-wrapper.jar: \
${JBOSS_HOME}server/mobi/lib/javax.servlet.jar:${JBOSS_HOME}server/mobi/lib/mail.jar: \
${JBOSS_HOME}server/mobi/lib/hsqldb-plugin.jar:${JBOSS_HOME}server/mobi/lib/jboss.jar: \
${JBOSS_HOME}server/mobi/lib/jpl-pattern.jar:${JBOSS_HOME}server/mobi/lib/log4j.jar: \
${JBOSS_HOME}server/mobi/lib/hsqldb.jar:${JBOSS_HOME}server/mobi/lib/jboss-jsr77.jar: \
${JBOSS_HOME}server/mobi/lib/jboss-monitoring.jar:${JBOSS_HOME}server/mobi/lib/commons-logging.jar: \
${JBOSS_HOME}server/mobi/lib/properties-plugin.jar:${JBOSS_HOME}server/mobi/lib/jboss-j2ee.jar: \
${JBOSS_HOME}server/mobi/lib/jmx-adaptor-plugin.jar:${JBOSS_HOME}server/mobi/lib/jpl-util.jar: \
${JBOSS_HOME}server/mobi/lib/jboss-jaxrpc.jar:${JBOSS_HOME}server/mobi/lib/mail-plugin.jar: \
${JBOSS_HOME}server/mobi/lib/jboss-jca.jar:${JBOSS_HOME}server/mobi/lib/snmp-support.jar: \
${JBOSS_HOME}server/mobi/lib/bsh-1.3.0.jar:${JBOSS_HOME}server/mobi/lib/jboss-saaj.jar: \
${JBOSS_HOME}server/mobi/lib/commons-httpclient.jar:${JBOSS_HOME}server/mobi/lib/jbosssx.jar: \
${JBOSS_HOME}server/mobi/lib/scheduler-plugin.jar:${JBOSS_HOME}server/mobi/lib/scout.jar: \
${JBOSS_HOME}server/mobi/lib/bindingservice-plugin.jar:${JBOSS_HOME}server/mobi/lib/javax.servlet.jsp.jar: \
${JBOSS_HOME}server/mobi/lib/jboss-management.jar:${JBOSS_HOME}server/mobi/lib/bcel.jar: \
${JBOSS_HOME}server/mobi/lib/scheduler-plugin-example.jar:${JBOSS_HOME}server/mobi/lib/autonumber-plugin.jar:  \
${JBOSS_HOME}server/mobi/lib/webcallbackhandler.jar: \
${JBOSS_HOME}server/mobi/lib/ReferenceGeneratorInterfaces.jar:${JBOSS_HOME}server/mobi/lib/jtds-1.1.jar: \
${JBOSS_HOME}server/mobi/lib/ojdbc14.jar:${JBOSS_HOME}server/mobi/lib/SeakeyComponents.jar: \
${JBOSS_HOME}server/mobi/lib/threadpool.jar:${JBOSS_HOME}server/mobi/lib/quartz.jar: \
${JBOSS_HOME}server/mobi/deploy/ejb.jar/SeaKeyBackEndModule.jar"


export log4j='/home/mas50o21/MessageReader/log4j.properties'

java -Xms160m -Xmx192m -cp "$CLASSPATH" com.mobiapps.seakey.emailclient.incoming.IncomingReader "$log4j"

can this be run as a service ?:
thanks
regards
shann

Your script is tough to read - for me at least.

I don't see basic things like exec, closing stdin, stdout, etc.

Try reading this see if it makes sense in the context of your shell script.
In general, it is possible to have a script "daemonized", but you have to do some things to make it work, so you need to use a robust shell like bash or ksh....

OTH, almost all daemons are written in low-languages like C, to my knowledge.

http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16

If you mean daemonize it by adding it to init, sure....if you mean daemonize it by having it listening on a port...yeah, that too is possible.

What exactly do you want to do, and I can give you the right idea. :)

This article has been dead for over six months. Start a new discussion instead.