File: ftplog2commonlog

package info (click to toggle)
analog 2:6.0-22
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 6,772 kB
  • sloc: ansic: 45,186; makefile: 279; perl: 249; sh: 49
file content (22 lines) | stat: -rw-r--r-- 729 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/perl
#
# Convert ftp logs to common log format so they can be processed by 
# standard web log processing software.
#
# Ftplog2Commonlog v. 1.0 is copyright 1995, 1996, 1997, 2000 by Joey Hess.
# May be distributed under the terms of the GPL.
#
# Usage:
# 	ftplog2commonlog < logfile
#

# Get the timezone offset. Needs a fairly new date command.
my $date=`date -R`;
($tzoffset)=$date=~m/( [+-]?\d+)$/;

while (<>) {
	($mon,$mday,$time,$year,$host,$size,$filename)=m/.*?\s+(.*?)\s+(\d+)\s+(.*?)\s+(\d+)\s+.*?\s+(.*?)\s+(\d+)\s+(.*?)\s+/;
	if (length($mday) == 1) { $mday="0$mday" }
	if (length($mon) == 1) { $mon="0$mon" }
	print "$host - - [$mday/$mon/$year:$time$tzoffset] \"GET $filename HTTP/1.0\" 200 $size\n";
}