LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-06-2004, 12:45 AM   #1
flosch
LQ Newbie
 
Registered: Jul 2003
Location: Austria
Distribution: RH9 mdk10 Gentoo!
Posts: 10

Rep: Reputation: 0
small bash script to kill a PID


Hello community!

tried to write a bash script which kill a certain PID

I tried to find out the PID wich works with
Code:
[root@pc20416 tmp]# pidof xmms
5586
for instance
now I like to kill this PID to shut down wvdial and finist the modem connection.

Code:
[root@pc20416 tmp]# x=pidof xmms
opens a new xmms instead of killing it!

thanks for help!
 
Old 05-06-2004, 02:10 AM   #2
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
You want to use command substitution, which is done with backticks in Bash:
Code:
#!/bin/bash
xmmspid=`pidof xmms`      # note backticks, not quotes!
kill $xmmspid

Håkan
 
Old 05-06-2004, 05:18 AM   #3
flosch
LQ Newbie
 
Registered: Jul 2003
Location: Austria
Distribution: RH9 mdk10 Gentoo!
Posts: 10

Original Poster
Rep: Reputation: 0
this works!!

thank you very much!!
 
Old 05-06-2004, 09:28 PM   #4
Technoslave
Member
 
Registered: Dec 2003
Location: Northern VA
Posts: 493

Rep: Reputation: 30
Alternately:

killall name_of_running_prog
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PID Kill Script or command ? Webmin rapture_1 Linux - General 1 11-02-2005 11:11 AM
Very small bash script enemorales Programming 8 02-25-2005 02:47 AM
bash script, monitoring running PID? thebover Programming 4 08-26-2004 02:42 PM
how do i kill a process from inside a bash script? mikaelo Programming 4 05-28-2004 08:51 AM
BASH script inform user and kill process mounters Programming 3 02-11-2002 04:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration