LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 11-20-2012, 06:28 PM   #1
TrollingForest
LQ Newbie
 
Registered: Nov 2012
Posts: 2

Rep: Reputation: Disabled
How do you stop or kill a shell script from working?


Hi. I was wondering how do you kill a shell script with another shell script? This is the script I want to freeze before it works.
------------------------

------------------------
#!/bin/sh
SHELL=/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local
HOME=/var/log

killprocs=`cat /usr/local/xxxx.kill.txt`

for proc in $killprocs; do
pid=$(ps -fe | grep $proc | awk '{print $2}')
if [[ -n $pid ]]; then
kill $pid
else
echo "NO PROCESS"
fi
done
-------------------------------------

xxxx.kill.txt, is a text document with a list of programs for example:

#EFFECTS
DeskShade
OmniDazzle
BumpTop
------------
and when you would want to open the program, it's killed by the shell script. So how might you freeze the shell script? Now I know removing the document would be easy, but what script can I create to stop the shell script from executing? Thanks!
 
Old 11-21-2012, 01:20 AM   #2
Stéphane Ascoët
Member
 
Registered: Feb 2004
Location: Orleans, 120 km south of Paris
Distribution: Mandrake, Freeduc (the one I'm making), Slackware, MacOS X
Posts: 111

Rep: Reputation: 20
Post I wonder what you want to do exactly but...

try kill -STOP
 
Old 11-21-2012, 07:15 AM   #3
TrollingForest
LQ Newbie
 
Registered: Nov 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
--the kill script is called xxxx.kill.sh
Thanks! Well, What I want to do exactly is this:

1. Create a shell script.
2. Make a script where the shell will freeze the xxxx.kill.txt. --
a. For example, Ill put this the simplest i possibly can.
---
killthescript=`cat /usr/local/xxxx.kill.sh`

for $killthescript; do
pid = killthescript
kill $pid (On activation) [The time when you open the program, OmniDazzle, it wont close from the kill script)
else
echo "xxxx.kill.sh is frozen from activation"
fi
done
--------------------------------------------------------
4. So when I open the program lets say, OmniDazzle,
The program(OmniDazzle) wont close from the "kill script"(xxx.kill.sh) but "kill-the-script" will activate and stop xxx.kill.sh from working and killing OmniDazzle when Omnidazzle opens.

5. So If I made a shall script, I could simply write out>>
--------------
#!/bin/sh
SHELL=/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local
HOME=/var/log

killscript=`cat /usr/local/xxxx.kill.sh`
kill -STOP
end
------------------
Or something along the lines of that? Yes, I know i wanted to really simplify things

Last edited by TrollingForest; 11-21-2012 at 07:20 AM.
 
Old 11-21-2012, 07:39 AM   #4
Stéphane Ascoët
Member
 
Registered: Feb 2004
Location: Orleans, 120 km south of Paris
Distribution: Mandrake, Freeduc (the one I'm making), Slackware, MacOS X
Posts: 111

Rep: Reputation: 20
Well I don't really undestand everything, wondering why such a complex thing? What's wrong with this three applications?
 
  


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
[SOLVED] Writing shell script to kill processes ben1173 Linux - General 1 10-19-2010 03:23 AM
How to use Shell script to kill an on going program? cruiz_bugs Programming 5 08-04-2009 08:41 AM
kill the process invoked from a shell script, when the script is killed kskkumar Linux - Software 8 05-23-2007 11:29 AM
shell script to kill all processes on specified port varunbihani Linux - General 1 04-19-2005 05:39 AM
Kill a process launched by a shell script gsbarry Programming 7 01-06-2004 02:09 PM


All times are GMT -5. The time now is 03:33 AM.

Main Menu
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