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-21-2005, 04:41 PM   #1
dr_zayus69
Member
 
Registered: Sep 2004
Location: western massachusetts
Distribution: fedora core 3, Suse 10
Posts: 877

Rep: Reputation: 35
shell script to read ps -e output and determine process double processes.


hi. I just noticed doing ps -e that there was three instances of mplayer running. I am thinking of making a script to search the output of pe -e and determine if there are multiples of a program running. i am not sure as to how i can go about storing the output in a variable to make it easy to test against. Can anyone steer me in the right direction? thanks for your replies in advance.
 
Old 09-21-2005, 06:37 PM   #2
bhar0761
Member
 
Registered: Jul 2005
Location: San Francisco
Distribution: Fedora Core 6
Posts: 64

Rep: Reputation: 15
simple approach would be to grep the results in a count based on line and run test on it

ps -e | grep mplayer | wc -l


store as variable and run test on it like

i=$(ps -e | grep mplayer | wc l)
if [ i -gt 1 ]
then
do
don
 
  


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
executing shell script in terminal directly with a double click kushalkoolwal Programming 15 11-26-2012 03:32 PM
how to execute a shell script in GUI by double click kamesh156 Programming 1 10-18-2005 06:25 AM
shell script to kill all processes on specified port varunbihani Linux - General 1 04-19-2005 06:39 AM
Redirecting process output to shell mhelles Linux - Newbie 1 04-30-2003 10:30 AM
How to determine whether a PROCESS is running, by a SHELL program? yuzuohong Linux - General 4 01-21-2003 09:41 PM


All times are GMT -5. The time now is 11:37 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration