Salman Basheer wrote:
>           Can anybody guide me writing a script which could either extract 
> the customized fields from access.log file or generate a new file with 
> customized fields. All I wanted from access.log file is 1) source IP address 
> 2) Requested URL and 3) Local Time.

A) Don't crosspost.
http://home.nyc.rr.com/computertaijutsu/linfaq.html#cross

B) Perl can do it easily, I'm assuming, given the usual format of log
files.  For example:

#!/usr/bin/perl -w
open(IN, "/var/log/access.log");
open(OUT, ">/tmp/accessData.log");

while($line = <IN>){
        chomp $line;
        @data = split(/\s+/, $line);
        print OUT "$data[0] $data[4] $data[37]\n";
}

That script opens access.log for reading, accessData.log for writing,
then reads all the lines from the IN file, gets rid of the newline,
splits the data at any whitespace into the @data array, then prints to
the OUT file the first, fifth and 38th elements of the data array.

If you have questions, there's a lot of info on the web about Perl.
Google is your friend.  Also, the O'Reilly book _Learning Perl_ is very
good for a new Perl hacker.

Chad Martin


To unsubscribe from this list, please email [EMAIL PROTECTED] & you will be 
removed. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/LINUX_Newbies/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to