#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    4
    Rep Power
    0

    shell script that reads a file


    Hi all!!

    I am totally new to shell scripting.

    I need a korn shell script that will monitor a log file (shown below). It should scan the log file for distinct ip addresses. When the log file is deleted or a new file is created, the shell script should detect that.

    For example, if at 11:00 pm the shell script detects 20 distinct ip addresses, and if at 11:10 the log file is deleted and a new one is created, then when we execute the script at 11:15, the shell script should return all the ip addresses (20 + the ip addresses from new file).

    Therefore, the shell script should finally give the number of current ip addresses (distinct) at the end. To make things more clear, this script is used to track the number of current users using a server.

    A snippet of log file is as shown below. 333.333.333.333 is the ip address. ip addresses are always preceded by the word AAD@.

    ------------------
    10:54:11 [crelay_child-106762-0]: Reading local IPC message...
    10:54:11 [crelay_child-106762-0]: Writing 220 bytes : LOGIN_MSG_RSP[-726510107](1)
    secu_server-0@myqsnhere.com->AAD@333.333.333.333
    10:54:12 [crelay_child-106762-0]: Scheduled send message to client on sfd 5

    ------------------

    Sorry if this is a tough question. Your help will be greatly appreciated.

    Thanks a lot in anticipation!!!

    chatguy2020.
  2. #2
  3. Introspective
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Nov 2001
    Location
    London, UK
    Posts
    3,317
    Rep Power
    110
    Just wondering if you have considered doing this in PERL - it's quite a lot more flexible than ksh for this sort of thing. I'd definitely use PERL for parsing and matching -type tasks like this.

    just a thought.

    christo
    This is me: http://chris.uk.com

IMN logo majestic logo threadwatch logo seochat tools logo