The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM
Home Forums Register Rules & FAQ Members List Arcade Search Today's Posts Mark Forums Read


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. Shell Script Page.


Other UNIX.COM Threads You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
creating /var/run csgonan UNIX for Dummies Questions & Answers 2 04-25-2007 07:11 AM
New Tool Searches and Replaces SCO Code Neo News, Links, Events and Announcements 3 08-11-2003 09:37 AM
creating jfs kburrows UNIX for Dummies Questions & Answers 6 10-17-2002 01:16 PM
grep: do multiple searches? sdemba UNIX for Dummies Questions & Answers 4 03-14-2002 05:32 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-07-2008
Registered User
 

Join Date: May 2008
Posts: 53
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Creating searches?

Hello. Could do with some help on where to get started really. If anyone could help me it would be greatly appreciated.

I have been working on this for a while now and I don't really know where to start but I am looking into creating a script that will process website hit files and output statistical information to the screen.

I have all of the hit files already and i have them populated like this:

137.44.2.8 Mon Feb 4 22:02:35 GMT 2008
149.192.2.81 Mon Feb 4 23:22:12 GMT 2008
132.53.17.171 Tue Feb 5 01:56:16 GMT 2008

What i want to do is create script(s) that will:

1. Request from the user a particular time period of interest for them to search all of this information

2. find

(i) the number of hits occurring during the given time period, and

(ii) the number of hits from unique IP addresses (counting two as one)

3. Present this information in table with the headings “page”, “hits” and “unique hits”


Also all the hit files are stored in a hits directory and I want the script to be executed from the parent directory of hits.

Again if anyone can point me in a good direction this would be greatly appreciated.

All i can think of so far is using "if" functions. but this is the first time i have used unix. (im using SUSE10.3 if that helps?) i just really wanted some pointers/solutions.

thanks for your time.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-12-2008
Smiling Dragon's Avatar
Disorganised User
 

Join Date: Nov 2007
Location: New Zealand
Posts: 565
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
I'd suggest working with perl for this as it's rather good at parsing files and creating nicely formatted reports.

Here's some pseudo-code to help get you going:
Code:
#!/usr/local/bin/do-what-i-want-not-what-i-write
print "Start date to search from: "
read from STDIN to $datestart
print "End date to search up until: "
read from STDIN to $dateend
print "File to search on: "
read from STDIN to $file

$hitcount=0
new array($iplist)

while (read $line from $file) {
  split $line into ($ip,$date)
  if ($date >= $datestart && $date <= $dateend) {
    $iplist[$ip]++
    $hitcount++
  }
}
$hitcount_unique=arraysize($iplist)
print_pretty_report($hitcount,$hitcount_unique)
Reply With Quote
  #3 (permalink)  
Old 05-12-2008
Registered User
 

Join Date: May 2008
Posts: 53
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
**************Thread Closed *****************************
Reply With Quote
Google UNIX.COM
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

vB 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 -7. The time now is 04:12 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102