The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Small Search script appu1987 Shell Programming and Scripting 2 06-03-2008 11:14 PM
small script help ali560045 Shell Programming and Scripting 9 01-18-2008 10:18 AM
Very small Shell Script Help... marconi Shell Programming and Scripting 2 12-11-2007 05:44 AM
small script help rkl1 Shell Programming and Scripting 1 12-06-2005 11:26 PM
Need help in a small script super_duper_guy Shell Programming and Scripting 2 10-24-2005 11:06 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-06-2007
everurs789 everurs789 is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 14
small script

Hi,

I am new to unix shell scripting. I just want a little script to check the no. of processes are equal to 8, then echo a successful message otherwise echo a unsuccessful message. Please help.

Thanks.
  #2 (permalink)  
Old 11-06-2007
earnstaf earnstaf is offline
Registered User
  
 

Join Date: May 2007
Posts: 113
Quote:
Originally Posted by everurs789 View Post
Hi,

I am new to unix shell scripting. I just want a little script to check the no. of processes are equal to 8, then echo a successful message otherwise echo a unsuccessful message. Please help.

Thanks.
Maybe something like:
Code:
process=`ps -ef | wc -l`

if [ "$process" -eq 8 ]; then
  echo "8 processes running" 
elif [ "$process" -lt 8 ]; then
  echo "Less than 8 processes running"
elif [ "$process" -gt 8 ]; then
  echo "More than 8 processes running"
fi
  #3 (permalink)  
Old 11-06-2007
gus2000 gus2000 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 157
Oh no, you're going to get everurs789 an "F" on his homework.

Code:
typeset -i process=$(($(ps -e|wc -l)-1))
[[ $process -eq 8 ]] && echo PASS || echo FAIL
Simple, right?
  #4 (permalink)  
Old 11-06-2007
everurs789 everurs789 is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 14
Thanks a bunch all...
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:52 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0