The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perl script variable to read shell command bulkbiz Shell Programming and Scripting 4 10-10-2008 03:05 AM
How to read email using mailx in shell script or perl jliharper Shell Programming and Scripting 4 03-23-2008 06:57 AM
Get real value from real-time systems iBot Complex Event Processing RSS News 0 01-14-2008 02:10 AM
average transaction time nhatch Shell Programming and Scripting 2 05-02-2007 09:11 AM
WARNING: correctable error from pci0 (upa mid 0) during dvma read transaction. visveswaran IP Networking 1 09-28-2005 10:21 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-25-2009
bruno406 bruno406 is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 3
Perl or Shell script to read a transaction log in real time

Hello,
I have a Apache webserver running on RedHat. Its primary function is a proxy server for users accessing the internet. I have a transaction log that logs every transactions of every users. For users trying to access certain sites/content the transactions goes into a 302 redirect loop and the browser eventually throws the error. Basically I need a script that will continuously watch the transaction log in real time and if it sees 5 or more consecutive redirect from the same user to to same site then redirect them to a certain site like http://testsite.com
Below is the transaction log format

sourceIP of the end user <timestamp> content/site being accessed result code

206.40.1.2 [25/Feb/2009:09:13:36 -0600] GET Google HTTP/1.1" 302

So if the script sees something like below then the last redirect would be http://testsite.com

206.40.1.2 [25/Feb/2009:09:13:36 -0600] GET Google HTTP/1.1" 302
206.40.1.2 [25/Feb/2009:09:13:37 -0600] GET Google HTTP/1.1" 302
206.40.1.2 [25/Feb/2009:09:13:38 -0600] GET Google HTTP/1.1" 302
206.40.1.2 [25/Feb/2009:09:13:39 -0600] GET Google HTTP/1.1" 302
206.40.1.2 [25/Feb/2009:09:13:40 -0600] GET Google HTTP/1.1" 302

Any help would be really appreciated.

Thanks

Bruno
  #2 (permalink)  
Old 02-25-2009
KevinADC KevinADC is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2008
Posts: 731
File::Tail (perl CPAN module) can be used to read the log file but you would still have to write code to perform your specific requirement of redirecting after five 302s. I have also never used the module so can't help with specifics if you decided to look into it.
  #3 (permalink)  
Old 03-03-2009
bruno406 bruno406 is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 3
Thanks Kevin.
Has any one used the File::Tail module for similar purpose before? I've not used that module and not that proficient on perl so if anyone can share the code where it can tail the file and read that would be really helpful. If not perl, any other scripts would also be helpful.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0