The UNIX and Linux Forums  


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
Snoop Script tafil Shell Programming and Scripting 2 07-30-2008 03:24 AM
Howto make an URL world readable monkfan UNIX for Dummies Questions & Answers 3 04-11-2007 12:16 PM
Script to move certain number of files every 10 minutes. amitsayshii UNIX for Dummies Questions & Answers 1 02-26-2007 04:55 AM
Howto read data into a shell script banjo Shell Programming and Scripting 4 09-06-2006 07:41 AM
Convert minutes to hours, minutes, seconds Vozx Shell Programming and Scripting 1 12-09-2005 01:24 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 05-27-2009
tindasz tindasz is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 6
Quote:
Originally Posted by matrixmadhan View Post
just this would do

Code:
PID=$!

and no need for an echo command


Code:
kill -2 $PID


Code:
if not kill -9 $PID

no brutal kill in the beginning itself

-----Post Update-----





there are some problems to this

snoop from other users
grep itself is a process
and the last - when something is available for free in the form of $! you don't have to work on it again
--------
maybe i can script like this before implemented at my box, please kindly give me your correction.

snoop -o /var/test.pcap -d e1000g0
PID=$!
sleep 600
kill -2 PID

that's one right?
  #2 (permalink)  
Old 05-27-2009
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
Quote:
snoop -o /var/test.pcap -d e1000g0
PID=$!
sleep 600
kill -2 PID
snoop should run as background process using ' & '
PID variable should be used and not literal as such
kill -2 $PID
  #3 (permalink)  
Old 05-27-2009
devtakh devtakh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore
Posts: 514
Or you can capture it using grep and awk


Code:
PID=`ps -ef | grep snoop | awk '{print $2}'`
kill -9 $PID

[ $2 or $3 in awk depending on your output]


-Devaraj Takhellambam
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 12:46 AM.


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