MESSAGE
DATE | 2002-10-02 |
FROM | Ruben I Safir
|
SUBJECT | Re: [hangout] Cgi Search
|
This doesn't do what you want but it does walk the file tree.
#!/usr/bin/perl -w
my $file= '/usr/local/apache/htdocs'; ftw($file);
sub ftw{ local *SITE; #print "OPEN FTW \n\n"; my $file = shift; opendir SITE, $file or die "$! $file"; my -at-files = grep{$_ !~ /^\./}readdir(SITE); while(my $test = shift -at-files){ if( -d "$file/$test"){ # print "DIRECTORY: $file/$test\n"; ftw("$file/$test") ; next; } #print "FILE $file/$test\n"; if ($test =~ /html$/){ if(open FILE, "<$file/$test"){ open FILE2, ">$file/$test\.bak"; while(){ my $line = $_; if($line =~ /10025/){ print "$file/$test: $line"; $line =~ s/10025/10022/g; print "CHANGED: $file/$test: $line\n";
} print FILE2 "$line\n"; } } close FILE; close FILE2; } } # print "CLOSE FTW\n\n";
}
On 2002.10.02 16:04 joev_nylxs-at-pipeline.com wrote: > > I could use some help here, I need to create a search of a directory of html > files. The search would be a search for a word or phrase contianed on one in > one or more of those files. I'm thinking of opening a pipe from the perl > script to grep to do this. Is this the best way? I'm pretty sure this opens a > big security hole. > > Thanks > Joe > ____________________________ > New Yorker Free Software Users Scene > Fair Use - > because it's either fair use or useless.... > -- __________________________
Brooklyn Linux Solutions __________________________ DRM is THEFT - We are the STAKEHOLDERS http://www.nyfairuse.org
http://www.mrbrklyn.com - Consulting http://www.nylxs.com/radio - Free Software Radio Show and Archives http://www.brooklynonline.com - For the love of Brooklyn http://www.nylxs.com - Leadership Development in Free Software http://www.nyfairuse.org - The foundation of Democracy http://www2.mrbrklyn.com/resources - Unpublished Archive or stories and articles from around the net http://www2.mrbrklyn.com/mp3/dr.mp3 - Imagine my surprise when I saw you... http://www2.mrbrklyn.com/downtown.html - See the New Downtown Brooklyn....
1-718-382-5752
____________________________ New Yorker Free Software Users Scene Fair Use - because it's either fair use or useless....
|
|