No. 1 Story

HP job cuts loom for Australian employees

A number of Australian employees of Hewlett-Packard are facing the loss of their jobs as the global computer giant looks to slash its worldwide workforce by up to 30,000.

read more

Related Articles

Write, your, own, Linux, server, part, two
In only a couple of years, millions of Australians will directly be using the...

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