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
what is wrong with this tr -d? cleansing_flame UNIX for Dummies Questions & Answers 3 02-06-2008 12:34 PM
sth wrong of gcc zither AIX 2 01-02-2008 01:57 AM
What’s wrong with the following? vrn UNIX for Dummies Questions & Answers 8 03-19-2006 09:09 PM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 01-17-2004
Blip Blip is offline
Registered User
  
 

Join Date: Jan 2004
Posts: 27
where have i gone wrong?

ok, i wrote a script called purge.sh
which i referred to in another thread. It prompts the user for a keyword and a username and then kills all of the entered username's processes containing that keyword. However before it does that it asks you how many searches you wish to perform and sets a variable to contain that number, i later use a while loop to repeat the script until that number equals 0. Everything works in the script except for that it just loops infinitely and i cant figure out why. my explanation is pretty vague but the code from the script should help so here it is:


#!/bin/bash
echo "Purge: Search for and kill target process(EVERYTHING'S case
sensitive"
echo " "
echo -n "Enter amount of times you wish to search or kill a targe
t process:"
read query_number
while [ $query_number > "0" ]; do
echo -n "Enter search terms for the target process:"
read search_terms
echo -n "Enter user running process('all' for everyone):"
read process_host
if [ $process_host != "all" ]; then
process_line=$(ps -U $process_host | grep $search_terms)
echo $process_line
kill $process_line
else
process_line=$(ps -axc | grep $search_terms)
kill $process_line
fi
$query_number=$query_number - "1"
done


can anyone figure out whats wrong?

thanks, Blip
 

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 05:18 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