kill process help

i wanted to kill a process by entering the process name. How am i able to kill the process that allows user to enter the process name and kills it?

Maybe You have the command killall, then You can do

killall xmms

for example. If You don't have that You may have the command pidof, to find the process id of a named process.

i wanted to kill the process from entering the program name instead of the pid, how can i do so?

eg. when i do a "ps -f U username" it will print out all pid,ppid,C,stime,tty,stat,time,cmd. but i would like to kill the process by entering name of the program from the cmd column.

i use

grep programName | awk '{print $9}' | xargs kill

is not working!!!

Really hope there is someone to help me!!!

Have You tried killall instead of kill?

ps -f U username|grep programName | awk '{print $9}' | xargs killall

thanks Lakris!! it works!!! thanks!!!

but if i wanted to grep the input from user and kill the process how should i do it? i try but couldnt work!!!

echo "enter program name"
read input

ps -ef U username|grep $input | awk '{print $2}' | xargs killall

No problem, glad to help.
Not sure what isn't working for You, but maybe this will ( if You have $USER set)

echo "enter program name"
read input

ps -ef U $USER|grep $input | awk '{print $2}' | xargs kill

If You use $2 instead of $9 You will print the process id instead of program name. So use kill instead.

/Lakris