LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-19-2003, 02:21 PM   #1
ruchika
LQ Newbie
 
Registered: Aug 2003
Posts: 15

Rep: Reputation: 0
how to get PID without using pidof command?


Hi,

Just when I figured out how to use pidof with kill to signal a running process, I learnt that the embedded platform I am using does not support pidof and find commands. It does support other popular commands such as ps, grep, kill, ls though.

I have a shell script that gets a process's PID and sends it a signal.

kill -s testsig# $(pidof test)

Can someone help me do this without using pidof.

Thanks,
Ruchika
 
Old 09-19-2003, 02:38 PM   #2
SaTaN
Member
 
Registered: Aug 2003
Location: Suprisingly in Heaven
Posts: 223

Rep: Reputation: 33
kill -s SIGKILL `ps | awk '{if($4=="test")print $1 }'`

P.S :- Be careful with the quotes....
 
Old 09-22-2003, 03:12 PM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
$ pidof apache
708 707 706 705 704 687

$ ps -e | fgrep apache | sed -n 's/^ *\([0-9]*\).*/\1/p'
687
704
705
706
707
708
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I extract the pid field from ps aux command RajRed Linux - Newbie 7 12-09-2013 12:43 PM
PID Kill Script or command ? Webmin rapture_1 Linux - General 1 11-02-2005 11:11 AM
Getting PID from a system command in Linux perl script sumbabs Linux - General 1 03-03-2005 10:38 AM
/var/run/[XXX].pid - Tcl pid code liguorir Linux - Software 1 05-20-2004 10:32 PM
PID display command for kernel modules jedblack Linux - Software 1 11-28-2003 06:01 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:00 PM.

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