Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Posts
    25

    Unanswered: 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 16:39.

  2. #2
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    Code:
    while read user pid filler
    do
       killall -9 $pid
    done < tempFile
    Jean-Pierre.

  3. #3
    Join Date
    Jan 2004
    Posts
    25
    Thank you. Will try it out

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •