Re: [SLUG] Fun with perl

From: Jason Copenhaver (jcopenha@typedef.org)
Date: Fri Mar 22 2002 - 21:11:35 EST


if hssadmin always comes before 530 you can do

/hssadmin.*530/

or you could do if ($_ ~= /hssadmin/ && $_ ~= /530/)

or you could get O'riellys "Mastering Regular Expressions" and amaze the
kids in your neightborhood =)

On Fri, 22 Mar 2002, Brett Simpson wrote:

> Ok that works for me. How about two arguments? If I use /hssadmin|530/ I will get all lines that are either hssadmin or 530. But what I want is lines that have both the hssadmin and 530.
>
> Thanks,
>
> Brett
>
>
> >>> aharon@superfreeway.com 03/22/02 18:18 PM >>>
>
> Apparently LOG is a reserved word in perl.. Try changing it to:
>
>
> open (logtest,"/var/www/html/auth.log");
> while (<logtest>) {
> if ($_ =~/hssadmin/) {
> print "$_<BR>\n";
> }
> }
> close (logtest)
>
>
> Aharon
>
>
> On Fri, 22 Mar 2002, Brett Simpson wrote:
>
> >
> > I'm getting errors when I try this from my browser & the command line.
> >
> > Can't take log of 0 at /var/www/cgi-bin/test.sh line 6.
> >
> > My line 6 is
> >
> > open (log,"/var/www/html/auth.log");
> > while (<log>) {
> > if ($_ =~/hssadmin/) {
> > print "$_<BR>\n";
> > }
> > }
> > close (log)
> >
> > >>> aharon@superfreeway.com 03/22/02 03:12PM >>>
> >
> > open (log,"/var/www/html/auth.log");
> > while (<log>) {
> > if ($_ =~ /joeuser/) {
> > print "$_<BR>\n";
> > }
> > }
> > close (log)
> >
> >
> > The reason it's jumbled is becuase you need to add <BR>'s to the end of
> > each line.
> >
> > Or you could simply add <PRE> before your print and </pre> after your
> > print.
> >
> > Example:
> > #!/usr/bin/perl
> > print "Content-Type: text/html \n\n";
> > print "<PRE>\n";
> > print `cat -b /var/www/html/auth.log | grep joeuser`;
> > print "</pre>\n";
> >
> > Aharon
> >
> >
> > On Fri, 22 Mar 2002, Brett Simpson wrote:
> >
> > > I'm looking to use this script in my apache cgi-bin so that users can list specific contents of a file in their web browser. It works ok except that it jumbles the lines togethor. Is there a cleaner way to do this so that it looks readable?
> > >
> > > #!/usr/bin/per
> > > print "Content-Type: text/html \n\n";
> > >
> > > print `cat -b /var/www/html/auth.log | grep joeuser`;
> > >
> > >
> > > Brett
> > >
> >
> >
>
>

-- 
"Without documentation you can never know what the code was meant to do,
only what it does"
	-- Rik van Riel (#kernelnewbies)



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 18:30:08 EDT