OK, how about this. The way to run it is:
$ rlog.date "`date '+%b. %e ..:..:.. %Y`"
Let me know what you think. Caveat - No warranty, etc.
If somebody knows how to format the date above using perl, let
me know. Or even better, how do you get the output from a shell
command in perl available to the program?
davek
Here's the source:
#!/usr/bin/perl
########################################################################
# $Id: rlog.date,v 1.2 1996/10/28 23:14:27 root Exp $
#
# DESCRIPTION
# Prints raw RADIUS detail file for a specific date
#
# USAGE
# rlog.date "`date '+%b. %e ..:..:.. %Y`" <detailfile>
#
# The funky date command is to get the date in the right
# format, but not worry about the time. The above gives today's
# information. Different input would give different days.
#
#
# HISTORY
# Written 10/28/96 by Dave Kennedy <davek@muscle.net>
#
# I wrote this because I felt like it. :)
#
########################################################################
########################################################################
# Get the user name from the command line
$pat_date = $ARGV[0];
# Default detail file to use
$file = "/usr/adm/radacct/pm1/detail";
# Get the detail file specified on the command line if one given
if ($ARGV[1] ne "")
{
$file = $ARGV[1];
}
# Open the detail file
open(IN, $file) || die "Could not open file $file\n";
# Initialize some values
$pat_user = sprintf("User-Name = \"%s\"", $user);
$lookahead = <IN>;
while ($_ = read_record())
{
# chomp;
if (!length($_)) {
next;
}
if ($_ =~ $pat_date) {
print;
}
}
exit;
# Make the multi-line RADIUS record into one string
sub read_record {
$thisline = $lookahead;
LINE:
while ($lookahead = <IN>) {
if ($lookahead =~ /^[ \t]/) {
$thisline .= $lookahead;
}
else {
last LINE;
}
}
return $thisline;
}
-- | Dave Kennedy (davek@muscle.net) Voice: 770-368-1514 | | Multi-User Systems, Inc. Putting MUSCLE in Internet Access |