Couple of legacy web tricks.
Legacy way to combine text and a graphic.
<table>
<tr>
<td>
<img src="prof.png" alt="">
</td>
<td>06/01/2008 The Info pages are done <br> 06/09/2008 Locally on-line as of 03/05/2008 <br> 06/08/2009 Some web pages updated <br> 06/30/2010 Redoing student services web pages. <br> 09/15/2014 Menus are restructured
</td>
</tr>
</table
----------------------------------
Change text in many files with one command.
Say you want to duplicate some web pages to another server, but the web server names are different. That means all the links in the pages will be wrong. For example take the following simple web page:
[code]
<html>
<title> Offshore Educators (C1001) </title>
<title> Send us some comments </title>
<body bgcolor="aquamarine">
<CENTER><h2><B><I>Offshore Educators</I></B></h2></CENTER>
Sylabus: C1001 - Introduction to computing 1.
<hr>
<br>
<p>
This course introduces students to fundamental hardware concepts in the use of microcomputers and to some practical applications of software. The course focuses primarily on word processing, spreadsheets and business charts and presentation software using the Open Office products on the Linux platform. The course examines the use of computers for communication and collaboration including e-mail, conferencing software and the Internet for exploring the resources of the World Wide Web. Students participate in group discussions using groupware, work with computerized library databases and make decisions about the purchase of hardware, software and service providers.
</p>
<a href="descripts.html"> Returm me to the class listing</a>
<br>
<a href="http://oesrvr1"> Click on me to return to the homepage!</a>
</body
</html>
[/code]
Our goal is to change oesrvr1 to oemsrvr1. Now just for one file this is no big deal, unless you have tens or even hundreds of web pages. Then you are talking about a major project to change all the server names in links. This can be made real easy. After the web pages have been copied overto a new server, just go to the appropriate web directory such as /var/www on the new server and issue the following command:
$ sudo grep -lr -e 'oesrvr1' * | xargs sudo sed -i 's/oesrvr1/oemsrvr01/g'
In a few seconds all the files are changed without having to edit a single file. So now
"<a href="http://oesrvr1"> Click on me to return to the homepage!</a>" is changed to
"<a href="http://oemsrvr01"> Click on me to return to the homepage!</a>".
This command is for a nix based system, but you could share an MSWindows server web directory and let a nix box access the web directories via samba to make the needed changes. (Do it while the server is offline for security purposes.)
Go one step further to automate it using namechange.sh.
namechange.sh
[code]
sudo grep -lr -e '$1' * | xargs sudo sed -i 's/$1/$2/g'
[/code]
Be sure to make the program executable
$ chmod +x namechange.sh
Then at the command line you could use:
$ ./namechange.sh oesrvr1 oemsrvr01
More than one way to skin a cat. Hope this article helps you out. Definitely helped me out.
<table>
<tr>
<td>
<img src="prof.png" alt="">
</td>
<td>06/01/2008 The Info pages are done <br> 06/09/2008 Locally on-line as of 03/05/2008 <br> 06/08/2009 Some web pages updated <br> 06/30/2010 Redoing student services web pages. <br> 09/15/2014 Menus are restructured
</td>
</tr>
</table
----------------------------------
Change text in many files with one command.
Say you want to duplicate some web pages to another server, but the web server names are different. That means all the links in the pages will be wrong. For example take the following simple web page:
[code]
<html>
<title> Offshore Educators (C1001) </title>
<title> Send us some comments </title>
<body bgcolor="aquamarine">
<CENTER><h2><B><I>Offshore Educators</I></B></h2></CENTER>
Sylabus: C1001 - Introduction to computing 1.
<hr>
<br>
<p>
This course introduces students to fundamental hardware concepts in the use of microcomputers and to some practical applications of software. The course focuses primarily on word processing, spreadsheets and business charts and presentation software using the Open Office products on the Linux platform. The course examines the use of computers for communication and collaboration including e-mail, conferencing software and the Internet for exploring the resources of the World Wide Web. Students participate in group discussions using groupware, work with computerized library databases and make decisions about the purchase of hardware, software and service providers.
</p>
<a href="descripts.html"> Returm me to the class listing</a>
<br>
<a href="http://oesrvr1"> Click on me to return to the homepage!</a>
</body
</html>
[/code]
Our goal is to change oesrvr1 to oemsrvr1. Now just for one file this is no big deal, unless you have tens or even hundreds of web pages. Then you are talking about a major project to change all the server names in links. This can be made real easy. After the web pages have been copied overto a new server, just go to the appropriate web directory such as /var/www on the new server and issue the following command:
$ sudo grep -lr -e 'oesrvr1' * | xargs sudo sed -i 's/oesrvr1/oemsrvr01/g'
In a few seconds all the files are changed without having to edit a single file. So now
"<a href="http://oesrvr1"> Click on me to return to the homepage!</a>" is changed to
"<a href="http://oemsrvr01"> Click on me to return to the homepage!</a>".
This command is for a nix based system, but you could share an MSWindows server web directory and let a nix box access the web directories via samba to make the needed changes. (Do it while the server is offline for security purposes.)
Go one step further to automate it using namechange.sh.
namechange.sh
[code]
sudo grep -lr -e '$1' * | xargs sudo sed -i 's/$1/$2/g'
[/code]
Be sure to make the program executable
$ chmod +x namechange.sh
Then at the command line you could use:
$ ./namechange.sh oesrvr1 oemsrvr01
More than one way to skin a cat. Hope this article helps you out. Definitely helped me out.
Comments
Post a Comment