The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Net::FTPServer::XferLog - parse FTP server xfer logs.

SYNOPSIS

# XFERLOG file:

Mon Oct  1 17:09:23 2001 0 127.0.0.1 2611 1774034 a _ o r tmbranno ftp 0 * c
Mon Oct  1 17:09:27 2001 0 127.0.0.1 22 1774034 a _ o r tmbranno ftp 0 * c
Mon Oct  1 17:09:31 2001 0 127.0.0.1 7276 p1774034_11i_zhs.zip a _ o r tmbranno ftp 0 * c

# parse xfer log PROGRAM:

use Net::FTPServer::XferLog;
open T, 'test.xlog' or die $!;
my $hashref;
while (<T>) {
  $hashref = Net::FTPServer::XferLog->parse_line($_);
  map { print "$_ => $hashref->{$_} \n" } @Net::FTPServer::XferLog::field;
  print "-------------------";

}

# OUTPUT

day_name => Mon 
month => Oct 
day => 1 
current_time => 17:09:23 
year => 2001 
transfer_time => 0 
remote_host => 127.0.0.1 
file_size => 2611 
filename => 1774034 
transfer_type => a 
special_action_flag => _ 
direction => o 
access_mode => r 
username => tmbranno 
service_name => ftp 
authentication_method => 0 
authenticated_user_id => * 
completion_status => c 
-------------------
day_name => Mon 
month => Oct 
day => 1 
current_time => 17:09:27 
year => 2001 
transfer_time => 0 
remote_host => 127.0.0.1 
file_size => 22 
filename => 1774034 
transfer_type => a 
special_action_flag => _ 
direction => o 
access_mode => r 
username => tmbranno 
service_name => ftp 
authentication_method => 0 
authenticated_user_id => * 
completion_status => c 
-------------------
day_name => Mon 
month => Oct 
day => 1 
current_time => 17:09:31 
year => 2001 
transfer_time => 0 
remote_host => 127.0.0.1 
file_size => 7276 
filename => p1774034_11i_zhs.zip 
transfer_type => a 
special_action_flag => _ 
direction => o 
access_mode => r 
username => tmbranno 
service_name => ftp 
authentication_method => 0 
authenticated_user_id => * 
completion_status => c 
-------------------

DESCRIPTION

This parses xferlog(5) files into Perl hashrefs. The fields returned are shown in the synopsis. Note that the standard current-time field is returned as 5 separate fields here: day_name, month, day, current_time, year.

EXPORT

None by default.

AUTHOR

T. M. Brannon <tbone@cpan.org>

Thanks to Nic Heier for a doc fix. Thanks to Mike Edwards for pointing out a bug when parsing files with spaces in their name.

SEE ALSO

  • Net::FTPServer - secure, extensible Perl FTP Server

  • www.FAQS.org - FTP RFC is here

  • wu-ftpd, proftpd. These FTP servers started this xferlog syntax, Net::FTPServer supports it.

  • slicker solutions to dealing with filenames with many spaces

    http://perlmonks.org/?node_id=632864