BooBoo
03-07-2003, 06:42 PM
I can format a egrep to locate html files that have a certain line in it. However, the egrep is not working like I would like it to. The command is:
egrep -r -l -i "cp-app.cgi\?pg=ste_chkout_proc" /home/sites/*/web/*.htm* > proddisp.txt
It grabs all the html files at the web level, but will not go down further than that. I know on a couple of domains, I have subdirectories that definitely have that html code that I need to change. For example, egrep -l -i -r "cp-app.cgi\?secure=Y&pg=ste_chkout_proc" /home/sites/*/web/links/*.htm* > proddisp.txt
will find all files at this level.
After I get that working, I want to use this perlscript to make the changes:
#!/usr/bin/perl
# This may F*up your server, it's not my fault.
# Check it first on something you don't care about.
# I did not try it, I just coded it on the fly.
$text_file_name = "filename_above_with_all_your_paths_and_filenames";
open (DATA, "$textfile");
@data = <DATA>;
close DATA;
foreach $record(@data) {
$filename = $record;
open (FILE, "$filename");
@file = <FILE>;
close FILE;
@file =~ s/http://www.domainname.com/ccp5/cgi-bin/cp-app.cgi?&pg=ste_chkout_proc/https://www.domainnamecom/ccp5/cgi-bin/cp-app.cgi?secure=Y&pg=ste_chkout_proc/g;
open (FILE, ">$filename");
print FILE "@file";
close (FILE);
}
However, I do not think that this will work due to the / in it. How can I accomplish this?
I got the perl code from the Sun site from GregD. Thanks Greg!
egrep -r -l -i "cp-app.cgi\?pg=ste_chkout_proc" /home/sites/*/web/*.htm* > proddisp.txt
It grabs all the html files at the web level, but will not go down further than that. I know on a couple of domains, I have subdirectories that definitely have that html code that I need to change. For example, egrep -l -i -r "cp-app.cgi\?secure=Y&pg=ste_chkout_proc" /home/sites/*/web/links/*.htm* > proddisp.txt
will find all files at this level.
After I get that working, I want to use this perlscript to make the changes:
#!/usr/bin/perl
# This may F*up your server, it's not my fault.
# Check it first on something you don't care about.
# I did not try it, I just coded it on the fly.
$text_file_name = "filename_above_with_all_your_paths_and_filenames";
open (DATA, "$textfile");
@data = <DATA>;
close DATA;
foreach $record(@data) {
$filename = $record;
open (FILE, "$filename");
@file = <FILE>;
close FILE;
@file =~ s/http://www.domainname.com/ccp5/cgi-bin/cp-app.cgi?&pg=ste_chkout_proc/https://www.domainnamecom/ccp5/cgi-bin/cp-app.cgi?secure=Y&pg=ste_chkout_proc/g;
open (FILE, ">$filename");
print FILE "@file";
close (FILE);
}
However, I do not think that this will work due to the / in it. How can I accomplish this?
I got the perl code from the Sun site from GregD. Thanks Greg!
