Bourne Shell Script

I have created a Bourne shell Script in my 'bin' directory with the name of "Kill", but I need to know how to execute it from anywhere on the system in place of the 'kill'command (thus creating a "pseudo-command") that will process the pid(s) that I enter on the command line after the command (i.e. "kill 1234 1235) and will attempt to kill the processes through various kill levels with the -9 (kill attempt left for last since this is the most destructive.

Proper completion of this script will require an evaluation of what 'types' of kill should be executed and in what order.
BaseballAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BaseballAuthor Commented:
Adjusted points to 150
0
ozoCommented:
add your bin directory to $PATH
0
alexhudghtonCommented:
put your bin directory in your PATH variable BEFORE the real bin directory. This will ensure that your bin is found first when searching for commands
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

ozoCommented:
But the /usr/bin function is "kill", and the ~Baseball/bin function is "Kill".
It's usually safer to put your bin after the real bin, so that normal system functions don't change out from under you, and your scripts.
0
bedotCommented:
beware at modifying system commands: is dangerous to send a  kill -9 to some processes which need to clean their job before stopping;
 so for those, sending a kill -9 to them may left some unpretty files.

is not reasonable to give this possibility at all users.
is better to create another word to call your command (like uglykill, or crazykill), and place this new command in a directory accessible with the PATH variable;
in most system, there is a directory named /usr/local/bin or /usr/contrib/bin.

The PATH variable in a standard HPUX 10.20:
# echo $PATH
/usr/sbin:/usr/bin:/usr/ccs/bin:/usr/contrib/bin:/opt/nettladm/bin:/opt/pd/bin:/usr/bin/X11:/usr/contrib/bin/X11:/opt/upgrade/bin:/opt/hparray/bin:/sbin:/home/root
#

BUT only users having a good knowledge of unix are able to use your command safely.

REMEMBER, however, that when a process in in a system call, you cannot kill it, the signal never pass thru the user mode: so, your process can treat only in user mode (if your program is blocked in system mode, you can never kill it, with none level, including 9)



0
BaseballAuthor Commented:
I am looking to create a Bourne Shell Script in my 'bin' directory that I had to name "Kill", and I have to be able to execute it from anywhere on the system in place of the kill command. It wiil process the pid(s) that I enter on the command line after the command (ie "Kill 1234 1235") and it will attempt to kill the processes through various kill levels with the -9 (kill) attempt left for last since it is the most destructive.

Also, an evaluation of what 'type' of kill should be executed and in what order.

Please someone help me, I am not good at UNIX at all, so, please be very through.
0
ozoCommented:
How should an evaluation of what 'type' of kill be executed and in what order?
0
djveCommented:
Use the alias command to override the default system binary:

alias kill=<path to your kill script>

however your script can't know if the last kill failed because the process is hung, defunct or just slow to die and release resources.

If your writing the script for users it won't hurt you but if you use your script as root you run the risk of corrupting your system.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
thoellriCommented:
bourne shell? alias? Hello, anybody home? wake up!
0
alexhudghtonCommented:
I think you should put more effort into resolving the reasons why you are creating your script :-))

If you need a script of this nature, then you are probably going to be using it quite a lot - why ??

Do you have lots of processes that require killing? - what are they doing ? - why do you need to constantly kill them ?
0
ahoffmannCommented:
keep in mind that bash, csh, ksh, tcsh, zsh have a shell built-in kill command, so the PATH environment will not do the trick, usually
Simples method, ignoring all styleguides, etc. (see comments above), would be a alias
0
vvenksCommented:
Edit the PATH(or path) variable which would be specified in any of your .files(.login,.profile,.cshrc) as given below:
path=$PATH:~/bin
$PATH i hope you know is holding your path and ~stands for $HOME,so that you are now specifying a secondary path for all your command execution.
                                                                          Bye.
0
doug_levittCommented:
Add the ~/bin directory to your $PATH
0
ahoffmannCommented:
NO: ~ does not stand for $HOME (it's just the same, sometimes)
NO: path=$PATH:~/bin  will not work in .cshrc or .login
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.