This is syslog.newlines.pl in view mode; [Download] [Up]
#!/usr/bin/perl ############################################################################### # # File: syslog.newlines.pl # RCS: $Header: $ # Description: find new lines in syslog files since date # Author: Christian Limpach <chris@nice.ch> # Created: Wed Apr 5 23:34:14 1995 # Modified: Fri Apr 7 04:44:50 1995 (Christian Limpach) chris@nice.ch # Language: Perl # Package: N/A # Status: Experimental (Do Not Distribute) # # (C) Copyright 1995, Christian Limpach, all rights reserved. # This is free software, and you are welcome to redistribute it # under certain conditions; see ftp://nice.ethz.ch/users/chris/TERMS # for details. This software comes with ABSOLUTELY NO WARRANTY. # ############################################################################### require 'timelocal.pl'; sub date2utc { my($mon,$mday,$hours,$min,$sec) = $_[0] =~ /([jJfFmMaAsSoOnNdD][aAeEpPuUcCoO][nNbBrRyYlLgGpPtTvVcC]) ([ \d]\d) (\d\d):(\d\d):(\d\d)/; my(%monthnames) = ('JAN',0,'FEB',1,'MAR',2,'APR',3,'MAY',4,'JUN',5, 'JUL',6,'AUG',7,'SEP',8,'OCT',9,'NOV',10,'DEC',11); my($time); if($mon) { $year = (localtime(time))[5]; $mon =~ tr/a-z/A-Z/; $mon=$monthnames{$mon}; $time=timelocal($sec,$min,$hours,$mday,$mon,$year); $time=timelocal($sec,$min,$hours,$mday,$mon,--$year) if ($time > time); $time; } else { -1; } } sub syslog_newlines { my($file, $date) = @_; my($last)=0; $date = date2utc($date) if ($date == 0); open(f, "<$file"); while (<f>) { $last = date2utc($_); print if ($date < $last); } close f; $last?$last:$date; } if ($0 =~ /syslog.newlines.pl$/) { die "usage: $0 file since [time-stamp-file]\n" unless ($#ARGV==1 || $#ARGV==2); ($file, $since) = @ARGV; $since = hex($since) if $since =~ /^0x[0-9a-fA-F]*$/; if ($#ARGV==2) { open(ts, ">$ARGV[2]"); printf ts "0x%x\n", syslog_newlines($file, $since); close ts; } else { printf stderr "0x%x\n", syslog_newlines($file, $since); } } 1;
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.