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 11-09-2003, 12:34 AM   #1
macie
Member
 
Registered: Oct 2003
Location: /dev/null
Posts: 33

Rep: Reputation: 15
check user processes


i need to figure out a way to be able to catch a user's pid number of a particular running process.

for example:

There are 7 users logged in. Each user runs a process called 'massx' One of the users called BOB needs to find out "his PID number" of process 'massx' ...all this needs to be within a script and echo his pid number to the console.

in other words:

running process = massx

get pid # of bob's massx process.

echo pid #

thx alot, any suggestions are apreciated...


peace.
 
Old 11-09-2003, 12:36 AM   #2
bdp
Member
 
Registered: Apr 2002
Distribution: RH 9
Posts: 230

Rep: Reputation: 30
how about

ps -aux |grep bob |grep massx
 
Old 11-09-2003, 12:59 AM   #3
macie
Member
 
Registered: Oct 2003
Location: /dev/null
Posts: 33

Original Poster
Rep: Reputation: 15


i considered that, but i need to be able to get the PID number by itself without all the extra info...
thx...
 
Old 11-09-2003, 02:00 AM   #4
bdp
Member
 
Registered: Apr 2002
Distribution: RH 9
Posts: 230

Rep: Reputation: 30
this works on my box:

ps -aux |grep BOB |grep massx >testdata
read variable < testdata
set -- $variable
first_parm=$1
second_parm=$2
echo $second_parm
 
Old 11-09-2003, 11:57 AM   #5
dkloes
Member
 
Registered: Oct 2003
Posts: 66

Rep: Reputation: 15
In the script:
pid=`ps -aux |grep bob |grep massx|grep -v grep|awk '{print $2}'`
echo $pid

You can test at the command line by just entering what is between the backquotes.
 
  


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
Safe to kill all user: 'nobody' processes? lagu2653 Linux - Security 4 11-06-2005 06:28 PM
How can I kill all processes form a certain user ? Menestrel Linux - Newbie 6 07-05-2005 09:53 AM
Limiting user processes? RecoilUK Linux - Security 1 04-09-2005 01:33 PM
Processes ran when a user is added? thrash.tux Linux - General 1 05-01-2004 12:47 AM
user processes skate Linux - Software 2 08-24-2003 05:51 AM

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

All times are GMT -5. The time now is 02:12 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