in reply to Program that will grep website for specified keyword

If you're on Linux you could say fgrep -Ri string

But if not, here's a hokey little program called sgrep (short for site grep).
#!/usr/bin/perl -w # grep through a website's HTML for a string. use File::Find; foreach my $term (@ARGV) { print "\n$term:\n"; find ({wanted => \&each_file, follow => 0, term => "$term"}, "/iputils/ns-home/docs"); } sub each_file { my $filename = $File::Find::name; return if ((-d $filename) || (! -r $filename) || (! -T $filename)); my $term = ${$_[0]}{term}; open (FILE, "$filename"); my $line = 0; while (<FILE>) { chomp; $line++; if ($_ =~ m/$term/) { print "$filename line $line\n"; } } close FILE; }


~~~~~~~~~~~~~~~
I like chicken.

Replies are listed 'Best First'.
Re: Re: In need of guidance....
by Stegalex (Chaplain) on Apr 24, 2002 at 20:21 UTC
    Oops, I forgot to mention that the part that says /iputils/ns-home/docs should be replaced with your server root directory.

    ~~~~~~~~~~~~~~~
    I like chicken.