Bootstrap scripts and scripts that call daemons often conform to a specified format. All scripts in the System V bootstrap procedure, e.g. scripts that are called by init, take standardized command line arguments. These arguments are "start" and "stop"; "restart" is often an additional argument featured in daemon scripts.

     When writing scripts that either start or stop a service, it is a good idea to conform to this format so that you can include them in the initilization directory "/etc/rc.d/init.d" if desired. The following examples demonstrate the use of these standard command line arguments.

case "$1" in
	start)
		echo "The daemon is starting"
		echo ""
		;;
	stop)
		echo "The daemon is stoping"
		echo ""
		;;
	restart)
		$0 stop
		$0 start
		;;
	*)
		echo "Usage: `basename $0` {start|stop|restart}" >&2
		#echo -e "Usage: $(basename "$0" [start|stop|restart]" >&2
		#exit 1
		;;
esac
exit 0
     In the script above, the case statement is used to query the command line argument "$1" which is the first argument to the script. If no argument is used or an invalid argument, it is trapped with the asterik "*" symbol and displays a usage statement. I also use the error exit code to help isolate problems should this script be used in the init process. Most scripts use "$0" in place of `basename "$0"` in the invalid argument trap message. The 'basename' command will trunicate the filename from it's path which is part of the "$0" perimeter.