If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > bash script read text file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-20-04, 15:36
pranav610 pranav610 is offline
Registered User
 
Join Date: Jan 2004
Posts: 25
bash script read text file

I am trying to read from a text file that i create using bash

<code>
#!/bin/bash

./apachectl stop
./apachectl start

ps -ef |grep httpd > tempFile

more tempFile
</code>

I want to be able to read the output from tempFile, look for pid and kill that pid using killall -9 <pid>

If it is possible, how?

tempFile

root 8711 1 0 15:02 ? 00:00:00 /usr/local/apache2/bin/httpd

nobody 8712 1 0 15:02 ? 00:00:00 /usr/local/apache2/bin/httpd

nobody 8713 1 0 15:02 ? 00:00:00 /usr/local/apache2/bin/httpd

Last edited by pranav610; 02-20-04 at 15:39.
Reply With Quote
  #2 (permalink)  
Old 02-21-04, 05:55
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
Code:
while read user pid filler
do
   killall -9 $pid
done < tempFile
__________________
Jean-Pierre.
Reply With Quote
  #3 (permalink)  
Old 02-23-04, 09:08
pranav610 pranav610 is offline
Registered User
 
Join Date: Jan 2004
Posts: 25
Thank you. Will try it out
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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