LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 05-24-2007, 11:40 AM   #1
arash8m
LQ Newbie
 
Registered: May 2007
Posts: 19

Rep: Reputation: 0
Simple script , error catch


Hi all,
I'm given the task to write a script that executes the file "stopet" which stops bunch of processes running in the background. As the processes are terminated, a message is displayed on the screen saying whether the termination was successful or not. Now I need to make my script so that it logs the processes that were not successfully terminated. Any help is appreciated.
 
Old 05-24-2007, 01:04 PM   #2
krizzz
Member
 
Registered: Oct 2004
Location: NY
Distribution: Slackware
Posts: 200

Rep: Reputation: 30
You can check the exit value of (I guess) kill command. Right after calling it store it's exit value and then check if it's zero or not:
Code:
kill $pid
exitval=$?
if [ "$exitval" != "0" ]; then
    echo "$pid was not terminated" >> log.txt
fi
I assume you have a pid or a process name

Last edited by krizzz; 05-24-2007 at 01:06 PM.
 
  


Reply



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
Simple Shell Script Error SBN Programming 11 03-19-2007 06:18 PM
Can't seem to run a simple shell script error command not found each time SimonT Linux - Newbie 5 10-29-2006 06:31 AM
catch Ctrl-C from shell script gecoool Programming 4 10-27-2005 01:19 AM
error in catch and try . code is attached ashwinipahuja Programming 6 07-05-2004 10:13 PM
simple script but error ryedunn Programming 4 03-11-2004 07:02 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:30 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
Open Source Consulting | Domain Registration