Perl or Shell script to read a transaction log in real time

Login or Register for Dates, Times and to Reply

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl or Shell script to read a transaction log in real time
# 1  
Perl or Shell script to read a transaction log in real time

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
Below is the transaction log format

sourceIP of the end user <timestamp> content/site being accessed result code [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 [25/Feb/2009:09:13:36 -0600] GET Google HTTP/1.1" 302 [25/Feb/2009:09:13:37 -0600] GET Google HTTP/1.1" 302 [25/Feb/2009:09:13:38 -0600] GET Google HTTP/1.1" 302 [25/Feb/2009:09:13:39 -0600] GET Google HTTP/1.1" 302 [25/Feb/2009:09:13:40 -0600] GET Google HTTP/1.1" 302

Any help would be really appreciated.


# 2  
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  
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.
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #680
Difficulty: Easy
Solaris was written in the C and C++ languages.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Log all the commands input by user at real time in /var/log/messages

Below is my script to log all the command input by any user to /var/log/messages. But I cant achieve the desired output that i want. PLease see below. function log2syslog { declare COMMAND COMMAND=$(fc -ln -0) logger -p local1.notice -t bash -i -- "$USER:$COMMAND" } trap... (12 Replies)
Discussion started by: invinzin21
12 Replies

2. Shell Programming and Scripting

How to read one row at time using shell script?

Hello Team, I need information on how to read one row at time using shell script. For example i have below data. service-description servername warning critical mountpoint disk-usage-tmp generic-service test1 80 90 /tmp disk-usage-var ... (6 Replies)
Discussion started by: ghpradeep
6 Replies

3. UNIX for Advanced & Expert Users

How to read a fast written log file at Real time speed?

Hello All, I am building a real time parser for a log file in my application. The log file is continuously written at a very fast pace and gets rolled over every 10 minutes. I have measured the speed and observed that around 1000 lines are written to it every second, each line about 30-40... (7 Replies)
Discussion started by: cool.aquarian
7 Replies

4. UNIX for Dummies Questions & Answers

I need a Script to read Log string and check date at the same time

I need to check 1 log file, which is logging: 2014-08-18T09:10:39+02:00 user: XXXXX START FEATURE 2014-08-18T09:10:39+02:00 user: XXXXX FINISH FEATURE I first need to check that the START FEATURE starts and finish on the same time/date for the same user, which is different each time START... (2 Replies)
Discussion started by: TheBest43
2 Replies

5. Shell Programming and Scripting

[solved] How to see log in real time?

Hi people I have a bash script with a line like this: python >> log & But i can't see anything in the log file while python program is running only if the program ends seems to write the log file. "$ cat log" for example don't show anything until the program ends. Is there... (4 Replies)
Discussion started by: Tieso
4 Replies

6. Shell Programming and Scripting

Shell script to convert epoch time to real time

Dear experts, I have an epoch time input file such as : - 1302451209564 1302483698948 1302485231072 1302490805383 1302519244700 1302492787481 1302505299145 1302506557022 1302532112140 1302501033105 1302511536485 1302512669550 I need the epoch time above to be converted into real... (4 Replies)
Discussion started by: aismann
4 Replies

7. Shell Programming and Scripting

shell script to replicate the log files from one location to another in real time

Hi, On the server, we have app log files in this location /app/logs/error.log On the same server, in a real time, we would like to replicate that into /var/ directory. if someone has already done this, please share the script. Thanks in advance. (4 Replies)
Discussion started by: lookinginfo
4 Replies

8. Shell Programming and Scripting

Perl :How to print the o/p of a Perl script on console and redirecting same in log file @ same time.

How can i print the output of a perl script on a unix console and redirect the same in a log file under same directory simultaneously ? Like in Shell script, we use tee, is there anything in Perl or any other option ? (2 Replies)
Discussion started by: butterfly20
2 Replies

9. Shell Programming and Scripting

bash script to count the time of transaction

Halo, Bash Script can get the time of process the trasaction or not? For example, bash script use to procee the trasaction, like select and checking.. then generate the XML. after it, i need to get the time which to count the process. Anyone can help me? Thank you (1 Reply)
Discussion started by: ryanW
1 Replies

10. UNIX for Dummies Questions & Answers

log users real time

hi.... how i can configurator a log file on real time....on unix solaris.... thanks a lot.... Best Regards... (3 Replies)
Discussion started by: chanfle
3 Replies

Featured Tech Videos