TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Shell Script for 'ps' (was Re: [TCLUG:17715] Aliasing)



On Tue, May 16, 2000 at 11:38:19AM -0500, Nick.T.Reinking@supervalu.com wrote:
> My whole point of doing this is because I type 'ps aux' out
> of habit, instead of 'ps -ef'.  Changing it to be ps-script isn't
> going to help me at all, here.  ;)  I just want my bad habits to
> work.  Sneef!

1. Create a bin directory in your home directory.
2. Add it to your PATH environment variable
3. Create a 'ps' shell script that examines $1

#!/bin/sh
####################################################################
# File: ps
# Desc: A shell script to get around the differences between Solaris
#       and Linux's ps utility options.  This one should let you
#	execute any set of options, assuming that if 'h' or 'H' is
#	found in $1, you're searching for help and any l.c. or u.c.
#	combination of 'aux' is equivalent to 'ps -ef'.
#
# By: Chewie <chewie@wookimus.net>
# Copyright: Public Domain...it's yours
#
# CAVEATTE: The location of this script MUST be found FIRST in your
# PATH environment variable, else the system 'ps' will execute
# instead.
# 	e.g. export PATH=${HOME}/bin:${PATH}
####################################################################

#### EDIT THESE DEFAULTS #####
PS=/bin/ps
OPTS=
##############################
   
function useage()
{       
	echo -e "\nUseage: $0 [aux|<solaris options>]"
	echo -e "e.g. $ ps aux (executes ps -ef)\n"
	echo -e "See also: man ps (1)\n\n"
	exit 1
}

case $1 in
	*[hH]*) useage ;;
	*[aA][uU][xX]*)
		# Rewrite option add to default above
		OPTS="${OPTS} -ef"

		# Shift command line params one to left 
		shift ;;  
	*) ;;
esac

exec ${PS} ${OPTS} $@

PGP signature