Business IT - Technology for your business

No. 1 Story

Telstra adds one million mobile services, but Sensis plummets

Telstra has revealed the addition of almost one million new mobile services in the six months to December 2011, but Sensis revenues plummeted 24 percent in 12 months.

read more

Write your own Linux server part two

Business IT - Open Source

99dwsvr

#!/bin/sh
#
# dwsvr  Bring up/down the dwserv process
#
# by David M. Williams

# -----------------------------------------------------------------------------
# Configurable options ...
# Comment out any of the following lines to use dwserv's default values.
# -----------------------------------------------------------------------------

DWSERV_DIR=.

# Edit the following to change the port number that dwserv
# runs at. Any client program must specify this port number to connect.
PORT=4000

# Edit the following to increase or decrease the connection queue. This
# probably need not be touched unless dwserv is expected to
# receive many simultaneous connections.
QLEN=5

# Turn on or off logging - use 'on' or 'off'
LOG=on

# Edit the following to specify where the logfile is to be stored - this
# will only take effect if logging is switched on (above).
LOGFILE=/tmp/dwsvr.log

# Edit the following to specify if verbose logging should be performed.
# This will create a larger log file but will give much more information
# about what is happening - use 'yes' or 'no'
VERBOSE=yes

# -----------------------------------------------------------------------------
# Nothing below here needs modification
# -----------------------------------------------------------------------------

getPID_Linux ()
{
 PID=`ps -e | grep dwserv | grep -v grep | cut -c1-5`
}

getPID_SunOS ()
{
 PID=`ps -ejf | grep dwserv | grep -v grep | cut -c10-14`
}

getPID=getPID_`uname`
$getPID

case "$1" in
 stop)
  if [ "a$PID" = "a" ];
  then
   echo "dwserv is not running"
   exit 1
  fi

  kill -9 $PID > /dev/null 2>&1
  sleep 1

  $getPID
  if [ "a$PID" = "a" ];
  then
   echo "dwserv stopped"
  else
   echo "dwserv could not be stopped"
  fi
  ;;

 start)
  if [ "a$PID" != "a" ];
  then
   echo "dwserv is already running"
   exit 1
  fi

  COMMANDLINE=

  if [ "a$PORT" != "a" ];
  then
   COMMANDLINE="$COMMANDLINE -p$PORT"
  fi

  if [ "a$QLEN" != "a" ];
  then
   COMMANDLINE="$COMMANDLINE -q$QLEN"
  fi

  if [ "$LOG" = "on" ];
  then
   COMMANDLINE="$COMMANDLINE -l"

   if [ "$VERBOSE" = "yes" ];
   then
    COMMANDLINE="$COMMANDLINE -v"
   fi

   if [ "a$LOGFILE" != "a" ];
   then
    COMMANDLINE="$COMMANDLINE -f$LOGFILE"
   fi
  fi

  $DWSERV_DIR/dwserv $COMMANDLINE > /dev/null 2>&1

  $getPID
  if [ "a$PID" = "a" ];
  then
   echo "dwserv could not be started"
  else
   echo "dwserv running"
  fi
  ;;

 *)
  echo "Usage: dwserv {start|stop}"
  if [ "a$PID" != "a" ];
  then
   echo "dwserv is running"
  else
   echo "dwserv is not running"
  fi
  exit 1
esac

Loading comments ...



- sponsored feature -

The Death of Traditional BI: What’s Next?

How to Make Business Discovery Work for Your Business IP PABX BUYING GUIDE

Business Discovery takes its cues from consumer apps. Like Google, it encourages us- ers to hunt for and explore data without worrying about or even noticing the underly- ing technology. Their entire experience is working within an intuitive interface to get real-time, self-service results with only minimal training. ...more