[wplug] replacing text within full website

Rick Smith rick at rbsmith.com
Tue Jan 6 08:00:34 EST 2004


On Mon, Jan 05, 2004 at 10:39:25PM -0500, Gentgeen wrote:
> 2)  When I do move it to production, I will need to change any of the
> links on the webpages from "http://kingpin/" to "http://www.foo.bar"  I
> tried my best to keep them to a minimum, but a few cgi scripts need full
> URL links.

What are the scripts written in?  Each language will have a way to
include another file.  In /bin/sh, use '. <filename>'.  If you are
on a RH or RH-like system, look in scripts in /etc/rc.d/init.d .
Those typically read in a file which define environment variables.
In Perl, there's 'require "<filename>";' 
The idea is to define in one file, variables that would change
if the web files are moved -- to another machine or to a different
directory.  Then when things are moved, one file can be changed rather
then hunting down all instances.

> the website consists of the servers root directory
> (/var/www/html/) and 5 sub-directories.  Spread throughout are about
> 15-20 links that would need changed.  Of course I could go though and
> check every page, then change them by hand with a little help from
> 'bluefish' and 'find...replace' action.  But I was wondering if anyone
> knew of an easier way.  My guess is some kind of script with using
> 'grep'.

  cd root-dir-for-web-pages
  grep -ril kingpin .

This will list all files in the directory hierarch that have 
kingpin or KINGPIN or KiNgPiN in them.  You can use the Perl
script offered in another post to do the changes.

> My script writing skills reflect my DOS BATCH file days, and I
> have not had the easiest time learning to master grep, so I would
> appreciate any help you can give me.

If you'd like, we can share a screen remotely (vnc or kibitz)
and get on the phone and work through this.

-- Rick



More information about the wplug mailing list