<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Shekhar Govindarajan's Blog &#187; html</title>
	<atom:link href="http://www.shekhargovindarajan.com/tag/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shekhargovindarajan.com</link>
	<description>My Notepad on the Web</description>
	<lastBuildDate>Tue, 07 Feb 2012 04:58:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com/" />
			<item>
		<title>Official WordPress app for Android</title>
		<link>http://www.shekhargovindarajan.com/google/official-wordpress-app-for-android/?&#038;owa_medium=feed&#038;owa_sid=&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=official-wordpress-app-for-android</link>
		<comments>http://www.shekhargovindarajan.com/google/official-wordpress-app-for-android/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 21:00:05 +0000</pubDate>
		<dc:creator>Shekhar</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[android market]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[blog site]]></category>
		<category><![CDATA[comment alert]]></category>
		<category><![CDATA[comment notification]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[gallery Ability]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[link and blockquote The editor]]></category>
		<category><![CDATA[messy Limited]]></category>
		<category><![CDATA[moderate]]></category>
		<category><![CDATA[multiple blogs]]></category>
		<category><![CDATA[official]]></category>
		<category><![CDATA[rich text editor]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.shekhargovindarajan.com/?p=1178</guid>
		<description><![CDATA[After having played with wpToGo app (though for a very short time), the announcement of an official WordPress app for Android phones caught my attention. These apps allow you to manage your blog posts and comments from your Android phone. I fired Android Market on my phone, searched for &#8220;wordpress&#8221; and the official app was [...]]]></description>
			<content:encoded><![CDATA[<p>After having played with wpToGo app (though for a very short time), the announcement of an official WordPress app for Android phones caught my attention. These apps allow you to manage your blog posts and comments from your Android phone.</p>
<p>I fired Android Market on my phone, searched for &#8220;wordpress&#8221; and the official app was right at the top, proudly named as WordPress, just WordPress. Yea, that&#8217;s indeed the official app!<span id="more-1178"></span>After installation, I launched the app. It prompted me for Blog URL, for which I supplied <a href="http://www.shekhargovindarajan.com">http://www.shekhargovindarajan.com</a>. For the username and password, I typed in the admin&#8217;s username and password, since I blog using the admin account. Subsequently, it allows me to manage comments, the blog posts and the pages on my blog. After playing with it for a couple of hours, I noticed the following pros and cons in the WordPress app for Android:</p>
<p><strong>Pros:</strong></p>
<ul>
<li>New comment(s) notification on the phone&#8217;s notification bar. You can set the app to check for comments every 5 mins to every 24 hours.</li>
<li>Ability to reply to comments</li>
<li>Comments moderation &#8211; approve, unapprove, mark spam</li>
<li>Nice tabbed interface with readable font. Big, touch friendly buttons</li>
<li>Ability to add images to the blog post from the phone&#8217;s gallery</li>
<li>Ability to compose a blog post on the phone, set it&#8217;s status to publish but publish it later on the blog site via &#8220;Upload Draft to Blog&#8221;.  Useful feature, when at times, we don&#8217;t have an active data connection on the phone.</li>
<li>Categories, once downloaded from the blog, are cached.</li>
<li>Ability to manage more than one WordPress based blogs.</li>
</ul>
<p><strong>Cons</strong></p>
<ul>
<li>No audio alert with the new comment alert</li>
<li>Limited editor options - bold, underline, italics, link and blockquote</li>
<li>The editor is not a rich text editor &#8211; the HTML tags show in the post&#8217;s text, which looks messy</li>
<li>Limited options to place the images &#8211; either at the top or at the bottom of a post</li>
<li>No option to delete a post once it is published, if by mistake</li>
<li>No option to insert a &#8220;read more&#8221; tag</li>
</ul>

<a href='http://www.shekhargovindarajan.com/google/official-wordpress-app-for-android/attachment/comments_moderation_and_reply_in_wordpress_android_app/' title='comments_moderation_and_reply_in_wordpress_android_app'><img width="150" height="150" src="http://www.shekhargovindarajan.com/wp-content/uploads/2010/02/comments_moderation_and_reply_in_wordpress_android_app-150x150.png" class="attachment-thumbnail" alt="The WordPress app allows to moderate and reply to comments, while on move" title="comments_moderation_and_reply_in_wordpress_android_app" /></a>
<a href='http://www.shekhargovindarajan.com/google/official-wordpress-app-for-android/attachment/messy_blog_post_without_a_rich_text_editor_in_wordpress_android_app/' title='messy_blog_post_without_a_rich_text_editor_in_wordpress_android_app'><img width="150" height="150" src="http://www.shekhargovindarajan.com/wp-content/uploads/2010/02/messy_blog_post_without_a_rich_text_editor_in_wordpress_android_app-150x150.png" class="attachment-thumbnail" alt="Without a rich text editor, posts with images look messy to edit" title="messy_blog_post_without_a_rich_text_editor_in_wordpress_android_app" /></a>
<a href='http://www.shekhargovindarajan.com/google/official-wordpress-app-for-android/attachment/wordpress_comments_notification_in_android_notification_bar/' title='wordpress_comments_notification_in_android_notification_bar'><img width="150" height="150" src="http://www.shekhargovindarajan.com/wp-content/uploads/2010/02/wordpress_comments_notification_in_android_notification_bar-150x150.png" class="attachment-thumbnail" alt="New comments on blog posts are notified using the Android&#039;s notification bar" title="wordpress_comments_notification_in_android_notification_bar" /></a>
<a href='http://www.shekhargovindarajan.com/google/official-wordpress-app-for-android/attachment/a_test_blog_post_via_wordpress_android_app/' title='a_test_blog_post_via_wordpress_android_app'><img width="150" height="150" src="http://www.shekhargovindarajan.com/wp-content/uploads/2010/02/a_test_blog_post_via_wordpress_android_app-150x150.png" class="attachment-thumbnail" alt="A test blog post with images, posted via the official WordPress app for Android" title="a_test_blog_post_via_wordpress_android_app" /></a>

<p>I found the WordPress app limiting when it comes to composing a blog post. This is because I like to use HTML lists (&lt;ul&gt;, &lt;ol&gt; and &lt;li&gt;) and I like to place images in between the post&#8217;s text. I may use the comment features &#8211; notification, moderation and reply. Someday, with upgrades and more features, the WordPress app may make it to <a title="http://www.shekhargovindarajan.com/google/my-list-of-must-have-android-apps/" href="http://" target="_blank">my list of must-have Android apps</a>.</p>
<img src="http://www.shekhargovindarajan.com/?ak_action=api_record_view&id=1178&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.shekhargovindarajan.com/google/official-wordpress-app-for-android/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Web Scraping with Firefox and PHP, using XPath</title>
		<link>http://www.shekhargovindarajan.com/scripts/web-scraping-with-firefox-and-php-using-xpath/?&#038;owa_medium=feed&#038;owa_sid=&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=web-scraping-with-firefox-and-php-using-xpath</link>
		<comments>http://www.shekhargovindarajan.com/scripts/web-scraping-with-firefox-and-php-using-xpath/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 02:00:58 +0000</pubDate>
		<dc:creator>Shekhar</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[automated]]></category>
		<category><![CDATA[automated Web scrapping]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[external tools]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[firexpath]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[PHP programmer]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[regular expressions]]></category>
		<category><![CDATA[scheduler]]></category>
		<category><![CDATA[screen scraping]]></category>
		<category><![CDATA[tidy]]></category>
		<category><![CDATA[Tidy library]]></category>
		<category><![CDATA[Use Curl library]]></category>
		<category><![CDATA[web browser]]></category>
		<category><![CDATA[Web page lie]]></category>
		<category><![CDATA[Web scarping]]></category>
		<category><![CDATA[web scraping]]></category>
		<category><![CDATA[well-formed Web page An XPath expression]]></category>
		<category><![CDATA[well-formed Web page content]]></category>
		<category><![CDATA[well-formed Web pages]]></category>
		<category><![CDATA[XHTML]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[xpath]]></category>

		<guid isPermaLink="false">http://www.shekhargovindarajan.com/?p=968</guid>
		<description><![CDATA[Last year, I faced two projects which required automated Web scrapping &#8211; to aggregate content from web pages. I evaluated different methods for Web scraping with varied level of success. Thanks to the changing structure of Web pages, non well-formed pages and URL redirects. Amongst using regular expressions and DOM (Document Object Model) parsing, I [...]]]></description>
			<content:encoded><![CDATA[<p>Last year, I faced two projects which required automated Web scrapping &#8211; to aggregate content from web pages. I evaluated different methods for Web scraping with varied level of success. Thanks to the changing structure of Web pages, non well-formed pages and URL redirects.</p>
<p>Amongst using regular expressions and DOM (Document Object Model) parsing, I used XPath too. XPath works great for well-formed Web pages. <span id="more-968"></span>A HTML Web page is called well-formed when all the opening tags have corresponding closing tags and the tags are nested properly (refer to <a href="http://en.wikipedia.org/wiki/Well-formed_element" target="_blank">this link</a> for more). A well-formed HTML page is also called an XHTML page.</p>
<p>XPath is a query language to access content on a well formed page &#8211; XHTML or XML. All the content in a Web page lie within HTML elements or tag pairs. The following is needed to extract out the content, of interest, using XPath from a Web page:</p>
<ol>
<li>A well-formed Web page</li>
<li>An XPath expression for the HTML element of interest</li>
<li>XPath query using the expression</li>
</ol>
<p>An XPath expression looks as cryptic as  .//*[@id='home_featured']/div. Here is where Firefox web browser with a plugin called FireXPath comes to help (as explained below). The second and third requirements are met by PHP (in my case) which is used for automated Web scrapping using the XPath expression.</p>
<p><strong>Click and build XPath expressions<br />
</strong>Building the cryptic XPath expression is easy and intuitive with Firefox and a couple of its plugins &#8211; namely Firebug and FireXPath. Install Firebug from <a href="https://addons.mozilla.org/en-US/firefox/addon/1843" target="_blank">here</a>, followed by FireXPath from <a href="https://addons.mozilla.org/en-US/firefox/addon/11900" target="_blank">here</a> and restart Firefox. As of this writing, I&#8217;m using the following versions of Firefox and the plugins:</p>
<ul>
<li>Firefox 3.5.6</li>
<li>Firbug 1.4.5</li>
<li>FireXPath 0.9.1</li>
</ul>
<p>After, the Firefox restart, browse to the Web page of your interest. Next:</p>
<ul>
<li>Launch Firebug by clicking on the bug like icon on the right corner of the status bar.</li>
<li>Click on the tab named XPath (in FireBug)</li>
<li>Click on the arrow (blue arrow) and move your mouse over the content, of interest, on the web page</li>
<li>Once the required chunk is highlighted (with a blue border), note down the XPath expression in the textfield.</li>
</ul>
<p>For example, the screenshot below, shows the XPath expression (.//*[@id='home_featured']/div  ) for the &#8220;Featured Post&#8221; chunk, on the home page, of this blog:</p>
<div id="attachment_974" class="wp-caption alignleft" style="width: 310px"><a href="http://www.shekhargovindarajan.com/wp-content/uploads/2010/01/XPath-Expression-With-FireXPath.png"><img class="size-medium wp-image-974   " style="display: block;" title="With FireXPath, point your mouse on the chunk/element of interest, to build an XPath expression" src="http://www.shekhargovindarajan.com/wp-content/uploads/2010/01/XPath-Expression-With-FireXPath-300x284.png" alt="With FireXPath, point your mouse on the chunk/element of interest, to build an XPath expression" width="300" height="284" /></a><p class="wp-caption-text">With FireXPath, point your mouse on the chunk/element of interest, to build an XPath expression</p></div>
<p>A few examples of XPath expressions:</p>
<ul>
<li>.//*[@id='latest_post']/span[1] : The posted and modified dates of the latest post on this blog &#8211; http://www.shekhargovindarajan.com</li>
<li>.//*[@id='top-stories']/div[1]/h2/a : The headline of the top story on Google News &#8211; http://news.google.com</li>
<li>.//*[@id='mp-tfa']/p[1] : Contents of featured article on Wikipedia &#8211; http://en.wikipedia.org/wiki/Main_Page</li>
</ul>
<p><strong>Automated scarping using PHP<br />
</strong>With the XPath expression in hand, a PHP script as follows, can extract out the required content from the Web page:</p>
<pre>&lt;?php

class WebScrap
	{
	private $url;
	private $xpath;

	public function WebScrap($url,$xpath)
		{
		$this-&gt;url = $url;
		$this-&gt;xpath = $xpath;
		}

	public function GetScrap()
		{
		// use Tidy to try to make the page well formed
		$page = $this-&gt;TidyIt($this-&gt;url);

		// create a document out of the well formed content
		$domDocument=new DOMDocument();
		$domDocument-&gt;loadHTML($page);

		// create an XPath object out of the document and query it for the supplied xpath
		$domXPath = new DOMXPath($domDocument);
		$domNodeList = $domXPath-&gt;query($this-&gt;xpath);

		// Get the content (HTML) out of the NodeList returned by the DOMXPath::query
		$content = $this-&gt;GetHTMLFromNodeList($domNodeList);

		return $content;
		}

	private function TidyIt($url)
		{
		$tidy = new tidy();
		$tidy-&gt;parseFile($url);
		$tidy-&gt;cleanRepair();
		return $tidy;
		}

	private function GetHTMLFromNodeList($domNodeList)
		{
		$domDocument = new DOMDocument();

		$node = $domNodeList-&gt;item(0);   

		foreach($node-&gt;childNodes as $childNode)
			$domDocument-&gt;appendChild($domDocument-&gt;importNode($childNode, true));

		return $domDocument-&gt;saveHTML();
		}

	}

?&gt;</pre>
<p>Note that, the function/method called GetScrap( ) of the WebScrap PHP class first calls the TidyIt( ) method. This function uses the <a href="http://en.wikipedia.org/wiki/HTML_Tidy" target="_blank">Tidy</a> library to fix (if required) the HTML for well-formedness. The PHP class for Tidy is used to fetch the web page via the given URL and repair it. Henceforth the DomXPath object is used to query the well-formed Web page content for the XPath expression.</p>
<p>To use the above code, you will need to install PHP modules for XML and Tidy. On a RedHat/CentOS/Fedora Linux machine, these modules can be installed using the following command:</p>
<pre>yum install php-xml php-tidy</pre>
<p>Save the above code in a file named class.WebScrap.php (say). Subsequently, the WebScrap class can be used as:</p>
<pre>&lt;?php

include("class.WebScrap.php");
$scrap = new WebScrap("http://news.google.com",".//*[@id='top-stories']/div[1]/h2/a");
print($scrap-&gt;GetScrap());

?&gt;</pre>
<p>The code should be self explanatory for a seasoned PHP programmer. If not, shoot your questions via comments to this post. For repeated and automated Web scarping, a scheduler like Cron can be used to execute the above PHP script at regular intervals and fetch the latest content.</p>
<p><strong>The Leftovers<br />
</strong>The code above is readable, crisp and focusses on the subject. For this reason, it has deliberate exclusions.  In a real world application, you should:</p>
<ul>
<li>Use <a href="http://php.net/manual/en/book.curl.php" target="_blank">Curl</a> library in PHP  or external tools like <a href="http://en.wikipedia.org/wiki/Wget" target="_blank">Wget</a> to fetch the URL. Then pass on the fetched content to Tidy. Hint: use the  parseString( ) of Tidy instead of parseFile( )</li>
<li>Handle errors in case of errors in Tidy and XPath.</li>
<li>Fallback to other means (say regular expressions) in case of errors in Tidy or XPath querying</li>
</ul>
<p>Note that XPath may not always give you the structured content that you desire. For example, using the expression .//*[@id='latest_post']/span[1] (for posted and modified dates of the latest post on this blog) will result into something as follows:</p>
<pre>&lt;strong&gt;Posted on:&lt;/strong&gt;
January 8, 2010
&lt;span class="dot"&gt;⋅&lt;/span&gt;
&lt;strong&gt;Last modified:&lt;/strong&gt;
January 8, 2010 @ 4:49 pm</pre>
<p>So there are tags and text (like &#8220;Posted on:&#8221; and &#8220;Last modified:&#8221;) to be stripped out, to get the posted date (January 8, 2010) and the modified date (January 8, 2010 @ 4:49 pm). For this, you may still have to use regular expressions and/or string manipulation functions like split( ).</p>
<img src="http://www.shekhargovindarajan.com/?ak_action=api_record_view&id=968&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.shekhargovindarajan.com/scripts/web-scraping-with-firefox-and-php-using-xpath/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>FTP Backups made easy</title>
		<link>http://www.shekhargovindarajan.com/tips-n-tricks/ftp-backups-made-easy/?&#038;owa_medium=feed&#038;owa_sid=&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ftp-backups-made-easy</link>
		<comments>http://www.shekhargovindarajan.com/tips-n-tricks/ftp-backups-made-easy/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 11:54:23 +0000</pubDate>
		<dc:creator>Shekhar</dc:creator>
				<category><![CDATA[Tips N Tricks]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[incremental]]></category>
		<category><![CDATA[lftp]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mirror]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[scheduled]]></category>
		<category><![CDATA[Secure Shell]]></category>
		<category><![CDATA[shared hosted server]]></category>
		<category><![CDATA[wget]]></category>
		<category><![CDATA[www.mysite.com]]></category>

		<guid isPermaLink="false">http://www.shekhargovindarajan.com/?p=862</guid>
		<description><![CDATA[I do not recall backing up data over FTP (File Transfer Protocol) in the near past. Thanks to the SSH (Secure SHell) suite of programs like SCP (Secure Copy) and SFTP (Secure FTP), and RSync. But recently I had to setup a scheduled and unattended backup of data lying on a shared hosted server using [...]]]></description>
			<content:encoded><![CDATA[<p>I do not recall backing up data over FTP (File Transfer Protocol) in the near past. Thanks to the SSH (Secure SHell) suite of programs like <a href="http://en.wikipedia.org/wiki/Secure_copy" target="_blank">SCP (Secure Copy)</a> and <a href="http://en.wikipedia.org/wiki/SSH_file_transfer_protocol" target="_blank">SFTP (Secure FTP)</a>, and <a href="http://en.wikipedia.org/wiki/Rsync" target="_blank">RSync</a>. But recently I had to setup a scheduled and unattended backup of data lying on a shared hosted server using FTP &#8211; the only available option at my disposal.<a href="http://en.wikipedia.org/wiki/Wget" target="_blank"></a></p>
<p><a href="http://en.wikipedia.org/wiki/Wget" target="_blank">Wget</a> is a popular and obvious choice to try out for FTP backups. But it didn&#8217;t work for me and threw an error saying cannot find .listing file. While I was about to dwell more into wget, I spotted the forgotten hero &#8211; lftp. <span id="more-862"></span>lftp is described as a &#8220;Sophisticated file transfer program&#8221;. Do not mistake sophistication with complexity. I found it simple to use for my task. I had to backup the data from the hosting server to a Linux based machine (running <a href="http://en.wikipedia.org/wiki/CentOS" target="_blank">CentOS</a>). I found lftp preinstalled on the machine. If not found installed, one can install it on a <a href="http://en.wikipedia.org/wiki/Red_Hat" target="_blank">RedHat</a>/<a href="http://en.wikipedia.org/wiki/Fedora_%28operating_system%29" target="_blank">Fedora</a>/CentOS based Linux by using the following command:</p>
<p><em>yum install lftp</em></p>
<p>To backup using lftp, the syntax is:</p>
<p><em>lftp  -p &lt;FTP-Port&gt; -u &#8216;&lt;FTP-Username&gt;&#8217;,'&lt;FTP-Password&gt;&#8217; -e &#8216;mirror &#8211;verbose &lt;FTP-Directory&gt; &lt;Local-Directory&gt; ;quit&#8217;   &lt;FTP-Host&gt;</em></p>
<p>For example:</p>
<p><em>lftp  -p 21 -u &#8216;shekhar&#8217;,'secret&#8217; -e &#8216;mirror &#8211;verbose /public_html /backup/website ;quit&#8217;   www.mysite.com</em></p>
<p>The above command will backup the subdirectories and files in the directory public_html of the website www.mysite.com to a directory named /backup/website on the local machine (on which the lftp command is executed). lftp will automatically create the local directory if it does not exist.</p>
<p>Note that the &#8220;mirror&#8221; option will backup only the files which have changed. This means for the first time, lftp will download/backup all the files from the site. But subsequently, lftp will backup only the new or edited files and directories. This option saves bandwidth by not re-downloading files, if the backup is up to date.</p>
<p>For scheduled and attended backups you can easily schedule a <a href="http://en.wikipedia.org/wiki/Cron" target="_blank">Cron</a> job with the above command. It&#8217;s simple, it works!</p>
<img src="http://www.shekhargovindarajan.com/?ak_action=api_record_view&id=862&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.shekhargovindarajan.com/tips-n-tricks/ftp-backups-made-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Display Microsoft Word&#8217;s Special Characters through Apache</title>
		<link>http://www.shekhargovindarajan.com/tips-n-tricks/display-microsoft-words-special-characters-through-apache/?&#038;owa_medium=feed&#038;owa_sid=&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=display-microsoft-words-special-characters-through-apache</link>
		<comments>http://www.shekhargovindarajan.com/tips-n-tricks/display-microsoft-words-special-characters-through-apache/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 04:18:36 +0000</pubDate>
		<dc:creator>Shekhar</dc:creator>
				<category><![CDATA[Tips N Tricks]]></category>
		<category><![CDATA[AddDefaultCharset]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Apache server]]></category>
		<category><![CDATA[Apache web server]]></category>
		<category><![CDATA[Apache web server side]]></category>
		<category><![CDATA[ascii]]></category>
		<category><![CDATA[Comment]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[ISO-8859-1]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mail server]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[operating system]]></category>
		<category><![CDATA[special characters]]></category>
		<category><![CDATA[text editor]]></category>
		<category><![CDATA[web browser]]></category>
		<category><![CDATA[web browser problem]]></category>
		<category><![CDATA[web server]]></category>
		<category><![CDATA[web server side]]></category>
		<category><![CDATA[weird characters]]></category>
		<category><![CDATA[word]]></category>

		<guid isPermaLink="false">http://www.shekhargovindarajan.com/?p=583</guid>
		<description><![CDATA[Recently, I carried out a Linux server upgrade for a client where I did a clean install of the latest operating system/distribution. Since it was a clean install I had to backup and note down the earlier configuration (of mail server, web server, database) and redo those changes. Mostly I preferred not to simply overwrite [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I carried out a Linux server upgrade for a client where I did a clean install of the latest operating system/distribution. Since it was a clean install I had to backup and note down the earlier configuration (of mail server, web server, database) and redo those changes. Mostly I preferred not to simply overwrite with the backed up configuration files. I rather documented and edited the configuration manually.</p>
<p>It all seemed to have gone smoothly and the new server has been up and running. But one not-so-fine day, the client started complaining that some HTML pages are not displaying properly. These were showing question marks (?) and some other weird characters. I figured out that these HTML pages were generated using Microsoft Word and had those special characters (closing quotes, double hyphens etc.). I discussed with the client that this could be a web browser problem because it is not able to use the correct character set.<span id="more-583"></span>But the client insisted that such pages used to display properly earlier, before the upgrade.  This meant I have missed redoing some configuration. The obvious suspect was at Apache web server side. After all it is Apache which is serving these web pages to the browser. Hence, if the culprit is not the web browser then it better be the web server. After parsing through the Apache&#8217;s configuration file I spotted a comment against a directive (or configuration option) called AddDefaultCharset which said:</p>
<p># Specify a default charset for all content served; this enables<br />
# interpretation of all content as UTF-8 by default.  To use the<br />
# default browser choice (ISO-8859-1), or to allow the META tags<br />
# in HTML content to override this choice, comment out this<br />
# directive:</p>
<p>I followed it and commented out the directive and voila it worked!</p>
<p>To sum up, if HTML files served by an Apache web server  are not displaying special characters properly in a web browser (IE, Firefox etc.), the solution is:</p>
<ul>
<li>Open the Apache&#8217;s configuration file named httpd.conf (found in the directory /etc/httpd/conf for RedHat based Linux distributions) in a text editor</li>
<li>Comment out, by prefixing a hash (#), the line which says &#8220;AddDefaultCharset UTF-8&#8243; such that it looks as follows:<strong> </strong><strong><br />
# AddDefaultCharset UTF-8<br />
</strong></li>
<li>Save the file and reload/restart Apache server. For RedHat based distributions you can do this via &#8220;service httpd reload&#8221;</li>
</ul>
<img src="http://www.shekhargovindarajan.com/?ak_action=api_record_view&id=583&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.shekhargovindarajan.com/tips-n-tricks/display-microsoft-words-special-characters-through-apache/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Slice out my latest post</title>
		<link>http://www.shekhargovindarajan.com/microsoft/slice-out-my-latest-post/?&#038;owa_medium=feed&#038;owa_sid=&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=slice-out-my-latest-post</link>
		<comments>http://www.shekhargovindarajan.com/microsoft/slice-out-my-latest-post/#comments</comments>
		<pubDate>Sun, 14 Sep 2008 21:44:08 +0000</pubDate>
		<dc:creator>Shekhar</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[beta 2]]></category>
		<category><![CDATA[Favorites bar]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[firefox 3]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[ie 8]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[internet explorer 8]]></category>
		<category><![CDATA[respective web sites]]></category>
		<category><![CDATA[syndicate]]></category>
		<category><![CDATA[syndication]]></category>
		<category><![CDATA[web browser]]></category>
		<category><![CDATA[web content]]></category>
		<category><![CDATA[web slice]]></category>
		<category><![CDATA[Web Slice Block]]></category>
		<category><![CDATA[Web Slice Body/Content]]></category>
		<category><![CDATA[Web Slice bookmark]]></category>
		<category><![CDATA[Web Slice preview]]></category>
		<category><![CDATA[Web Slice preview window]]></category>
		<category><![CDATA[Web Slice Title]]></category>
		<category><![CDATA[web slices]]></category>
		<category><![CDATA[webchunks]]></category>

		<guid isPermaLink="false">http://www.shekhargovindarajan.com/?p=296</guid>
		<description><![CDATA[The second beta of the upcoming version  of Microsoft&#8217;s Internet Explorer (IE 8 ) web browser was released last month. One of the touted features of IE 8 is Web Slices. Many of us cut out articles from the newspapers if we find them interesting. Think of Web Slices to be cuttings from Web sites. [...]]]></description>
			<content:encoded><![CDATA[<p>The second beta of the upcoming version  of Microsoft&#8217;s Internet Explorer (IE 8 ) web browser was released last month. One of the touted features of IE 8 is <strong>Web Slices</strong>.</p>
<p>Many of us cut out articles from the newspapers if we find them interesting. Think of Web Slices to be cuttings from Web sites. But with a difference. If these cuttings (web content) are updated on the respective web sites, you will be notified, as well as your cuttings will be updated. Technically, you &#8220;subscribe to a Web Slice&#8221;, instead of saying cutting it off which may offend the webmasters <img src='http://www.shekhargovindarajan.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>The latest post on my Blog is Web Slice enabled (or say, it is a Web Slice). In fact, it is Web Slice enabled since some time. Perhaps, some of you (who are using IE 8 ) would have noticed it.</p>
<p><span id="more-296"></span></p>
<p>Other web sites which are Web Slice enabled are digg.com, ebay.com, facebook.com, msn.com etc.</p>
<p><strong>How to subscribe to a Web Slice</strong></p>
<p>To slice out the latest post or to subscribe to the latest post on my blog:</p>
<ul>
<li>Download and install IE 8 from <a href="http://www.microsoft.com/windows/internet-explorer/beta/default.aspx" target="_blank">http://www.microsoft.com/windows/internet-explorer/beta/default.aspx</a></li>
<li>Once installed, browse to my blog at <a href="http://www.shekhargovindarajan.com/" target="_blank">http://www.shekhargovindarajan.com</a>.</li>
<li>Wait for the site to load up completely.</li>
<li>Once loaded you will notice, the &#8220;Subscribe to Web Slices&#8221; icon (the second icon, after the home icon on the top right) turns green as shown in the screenshot below:</li>
</ul>
<div id="attachment_301" class="wp-caption alignnone" style="width: 310px"><a href="http://www.shekhargovindarajan.com/wp-content/uploads/2008/09/subscribe_to_web_slices.png"><img class="size-medium wp-image-301" title="subscribe_to_web_slices" src="http://www.shekhargovindarajan.com/wp-content/uploads/2008/09/subscribe_to_web_slices-300x187.png" alt="A green icon indicates Web Slice(s) on the page" width="300" height="187" /></a><p class="wp-caption-text">A green icon indicates Web Slice(s) on the page</p></div>
<ul>
<li>Clicking on the green icon, will show you a dialog box which prompts you to add the Web Slice. Clicking the Add button, on the dialog, will place a bookmark on the Favorites bar.</li>
<li>Alternatively, if you move your mouse over the latest post, you will see a green border around the latest post, and a green icon on the left, as shown below:</li>
</ul>
<div id="attachment_308" class="wp-caption alignnone" style="width: 310px"><a href="http://www.shekhargovindarajan.com/wp-content/uploads/2008/09/subscribe_to_web_slices_2.png"><img class="size-medium wp-image-308" title="subscribe_to_web_slices_2" src="http://www.shekhargovindarajan.com/wp-content/uploads/2008/09/subscribe_to_web_slices_2-300x187.png" alt="Move the mouse over the latest post to subscribe to the Web Slice" width="300" height="187" /></a><p class="wp-caption-text">Move the mouse over the latest post to subscribe to the Web Slice</p></div>
<ul>
<li>By clicking on the green icon you can subscribe to the Web Slice.</li>
<li>Clicking on this bookmark will show you the preview of the Web Slice (the content of my latest blog post), as shown in the screenshot below:</li>
</ul>
<div id="attachment_309" class="wp-caption alignnone" style="width: 310px"><a href="http://www.shekhargovindarajan.com/wp-content/uploads/2008/09/web_slice_preview.png"><img class="size-medium wp-image-309" title="web_slice_preview" src="http://www.shekhargovindarajan.com/wp-content/uploads/2008/09/web_slice_preview-300x187.png" alt="Web Slice Preview" width="300" height="187" /></a><p class="wp-caption-text">Web Slice Preview</p></div>
<ul>
<li>Clicking on the arrow (-&gt;) icon on the preview window will take you to the full blog post.</li>
</ul>
<p><strong>How does it work ?</strong></p>
<p>If I write a new blog post which, upon publish, becomes my latest post, the Web Slice bookmark on your IE will turn bold. By default, the Web Slice is checked for any updates once in a day. Upon an update, the Web Slice bookmark can turn bold or even play a sound.</p>
<p>Right click on the Web Slice bookmark. Click on &#8220;Bold on Update&#8221;. This will make the bookmark bold, upon an update.</p>
<p>To play and sound, right click on the bookmark and select Properties. Click on the Settings button under &#8220;Update Schedule&#8221;. Check the box labeled &#8220;Play a sound when a monitored feed or Web Slice is updated.</p>
<p>Notice the numerous other options in the Properties window. Note that you can setup when to check the Web Slice for updates &#8211; which is by default set to 1 day.</p>
<p><strong>How to enable Web Slice on your site</strong></p>
<p>Refer to the URL <a href="http://msdn.microsoft.com/en-us/library/cc848871(VS.85).aspx" target="_blank">http://msdn.microsoft.com/en-us/library/cc848871(VS.85).aspx</a>. Read the section titled &#8220;Creating Web Slices&#8221;.</p>
<p>The rules are:</p>
<ol>
<li><strong>The Web Slice Block:</strong> You should have a HTML tag (like a &lt;DIV&gt;) enclosing the content that you want to Web Slice enable. This &lt;DIV&gt; tag must have the CSS class name set to &#8220;hslice&#8221; and must have an id. If you view source (the HTML source) of this blog, you will notice: &lt;<span class="start-tag">div</span><span class="attribute-name"> id</span>=<span class="attribute-value">&#8220;latest_post&#8221; </span><span class="attribute-name">class</span>=<span class="attribute-value">&#8220;hslice&#8221;</span>&gt; <span class="comment">Note that this &lt;div&gt; has the class set to hslice and id set to latest_post. The id must be unique. That is, no other element or tag on the page must have the same id. If you search for latest_post in the source, you will not find any other element with the same id.</span></li>
<li><span class="comment"><strong>The Web Slice Title: </strong>The title of the Web Slice or the content should be enclosed within a tag with the classname as entry-title. On my blog, I have given this class name to the anchor (&lt;a&gt;) tag which encloses the title of the latest blog post.<br />
</span></li>
<li><span class="comment"><strong>The Web Slice Body/Content:</strong> The content should be enclosed within a tag whose classname is entry-content. </span><span class="comment">Earlier the content of the latest post was enclosed within a paragraph tag (&lt;p&gt;). But giving the &lt;p&gt; tag, the class name as entry-title did not show the preview of the Web Slice (as shown in one of the screenshots above). Changing the &lt;p&gt; tag to a &lt;span&gt; tag showed the preview. Note that on my blog, the content of the latest post is either the full content (in some cases) or a part of the full content. In the latter case, clicking on continue reading shows you the full content. In the latter case, the Web Slice will be marked as updated only when I update the part of the content which shows in the latest post.<br />
</span></li>
</ol>
<p><span class="comment">To summarize, following is the markup structure of my latest blog post which is Web Slice enabled:</span></p>
<p>&lt;div id=&#8221;latest_post&#8221; class=&#8221;hslice&#8221;&gt;<br />
&#8212;<br />
&#8212;<br />
&lt;a class=&#8221;entry-title&#8221;  href=&#8221;&#8230;&#8221;&gt; the post title &lt;/a&gt;<br />
&#8212;<br />
&#8212;<br />
&lt;span class=&#8221;entry-content&#8221;&gt;<br />
the post content<br />
&lt;/span&gt;<br />
&#8212;<br />
&#8212;<br />
&lt;/div&gt;</p>
<p><strong>Issues with Web Slices</strong></p>
<p>Though Web Slices seem to be easy to implement, I thought of the following issues with them:</p>
<ol>
<li>For an existing site it may not be always straight forward to implement Web Slices if there are issues like &lt;p&gt; not working (as explained in point 3 in the above section). I would like to have no structure change to use Web Slices.</li>
<li>If you go through the link <a href="http://msdn.microsoft.com/en-us/library/cc848871(VS.85).aspx" target="_blank">http://msdn.microsoft.com/en-us/library/cc848871(VS.85).aspx</a>, you will notice a line which says &#8220;The Web Slice preview window will not always display content the exact same  way it appears on a Web page; some of the formatting is stripped away&#8221;. I could not find the documentation on what formatting is stripped away. I can see that, the Web Slice preview magically removes the continue reading, comments and category links (which are at the bottom of the latest post). And it magically redirects to the full post, when clicking on the -&gt; (arrow) on the preview button. How come, it is detecting the first link as a useful link and discarding other links. I like magic but would like to read the documented logic behind it.</li>
<li>Web Slice only works with IE 8, officially (read &#8220;Web Slices with Firefox&#8221; below). Perhaps, <a href="http://en.wikipedia.org/wiki/RSS_(file_format)" target="_blank">RSS</a> still remains the cross browser standard which works well to notify about updates.</li>
</ol>
<p><strong>Web Slices with Firefox</strong></p>
<p>With Firefox 3 and a plugin called Webchunks, you can use Web Slices in Firefox! It is very similar to using it in IE. First install the plugin from the following link <a href="http://disruptive-innovations.com/zoo/webchunks/webchunks-0.30.xpi" target="_blank">http://disruptive-innovations.com/zoo/webchunks/webchunks-0.30.xpi</a>. This is the direct link to the plugin. So launch it in Firefox 3.Once installed, it will ask for a Firefox restart. After restart, if you navigate back to my blog (or any other Web Slice enabled) site, you can subscribe to the Web Slices in a very similar way as shown in the screenshots below:</p>
<div id="attachment_323" class="wp-caption alignnone" style="width: 310px"><a href="http://www.shekhargovindarajan.com/wp-content/uploads/2008/09/firefox_subscribe_to_web_slices.jpeg"><img class="size-medium wp-image-323" title="firefox_subscribe_to_web_slices" src="http://www.shekhargovindarajan.com/wp-content/uploads/2008/09/firefox_subscribe_to_web_slices-300x187.jpg" alt="Clicking on the blue icon (on the left) will allow you to subscribe to a Web Slice (if any) on the page" width="300" height="187" /></a><p class="wp-caption-text">Clicking on the blue icon (on the left) will allow you to subscribe to a Web Slice (if any) on the page</p></div>
<div id="attachment_324" class="wp-caption alignnone" style="width: 310px"><a href="http://www.shekhargovindarajan.com/wp-content/uploads/2008/09/firefox_subscribe_to_web_slices-2.png"><img class="size-medium wp-image-324" title="firefox_subscribe_to_web_slices-2" src="http://www.shekhargovindarajan.com/wp-content/uploads/2008/09/firefox_subscribe_to_web_slices-2-300x187.png" alt="You can also subscribe to a Web Slice by moving the mouse over the content" width="300" height="187" /></a><p class="wp-caption-text">You can also subscribe to a Web Slice by moving the mouse over the content, as in IE 8</p></div>
<div id="attachment_325" class="wp-caption alignnone" style="width: 310px"><a href="http://www.shekhargovindarajan.com/wp-content/uploads/2008/09/firefox_web_slice_preview.jpeg"><img class="size-medium wp-image-325" title="firefox_web_slice_preview" src="http://www.shekhargovindarajan.com/wp-content/uploads/2008/09/firefox_web_slice_preview-300x187.jpg" alt="The Web Slice preview in Firefox 3" width="300" height="187" /></a><p class="wp-caption-text">The Web Slice preview in Firefox 3</p></div>
<p>To sum up, I do like the visual slicing out (e.g. by moving the mouse over on the latest post) of content from the web pages. It is like I&#8217;m indeed cutting and taking off something from the website <img src='http://www.shekhargovindarajan.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>Update:</strong></p>
<p>&#8220;And it magically redirects to the full post, when clicking on the -&gt; (arrow) on the preview button. How come, it is detecting the first link as a useful link and discarding other links. I like magic but would like to read the documented logic behind it.&#8221;</p>
<p>Found the logic behind this one. It follows the link (&lt;a&gt;) which has rel=&#8221;bookmark&#8221;. My latest blog post has two links (the title link and the continue reading link) whose rel=&#8221;bookmark&#8221;. Both of them point to the full post. So Web Slices is picking up one of them, either the first one or the last one. </p>
<img src="http://www.shekhargovindarajan.com/?ak_action=api_record_view&id=296&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.shekhargovindarajan.com/microsoft/slice-out-my-latest-post/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Microsoft launched a ringtone for Indians</title>
		<link>http://www.shekhargovindarajan.com/interesting/microsoft-launched-a-ringtone-for-indians/?&#038;owa_medium=feed&#038;owa_sid=&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=microsoft-launched-a-ringtone-for-indians</link>
		<comments>http://www.shekhargovindarajan.com/interesting/microsoft-launched-a-ringtone-for-indians/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 09:36:31 +0000</pubDate>
		<dc:creator>Shekhar</dc:creator>
				<category><![CDATA[Interesting]]></category>
		<category><![CDATA[aids]]></category>
		<category><![CDATA[Bill & Melinda Gates Foundation]]></category>
		<category><![CDATA[Bill Gates]]></category>
		<category><![CDATA[broadband]]></category>
		<category><![CDATA[CEO and founder]]></category>
		<category><![CDATA[condom]]></category>
		<category><![CDATA[ex CEO and founder]]></category>
		<category><![CDATA[hiv]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[india]]></category>
		<category><![CDATA[Internet connections]]></category>
		<category><![CDATA[Melinda Gates Foundation]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[MP3]]></category>
		<category><![CDATA[ringtone]]></category>
		<category><![CDATA[www.condomcondom.org]]></category>

		<guid isPermaLink="false">http://www.shekhargovindarajan.com/?p=132</guid>
		<description><![CDATA[Following is the link to the MP3 file of the ringtone: condom-a-cappella I must admit that the post title is just meant to be catchy. The ringtone was launched, day before, by a campaign funded by Bill &#38; Melinda Gates Foundation. Bill Gates is ex CEO and founder of Microsoft. That&#8217;s the one and only [...]]]></description>
			<content:encoded><![CDATA[<p>Following is the link to the MP3 file of the ringtone:</p>
<p><a href="http://www.shekhargovindarajan.com/wp-content/uploads/2008/08/condom-a-cappella.mp3">condom-a-cappella</a></p>
<p>I must admit that the post title is just meant to be catchy. The ringtone was launched, day before, by a campaign funded by Bill &amp; Melinda Gates Foundation. Bill Gates is ex CEO and founder of Microsoft. That&#8217;s the one and only connection with Microsoft <img src='http://www.shekhargovindarajan.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><a href="http://www.condomcondom.org/" target="_blank">http://www.condomcondom.org/</a> is the website of this campaign. The ringtone can be downloaded from this site too.</p>
<p>The website is meant for Indian masses and aims to create awareness about HIV and AIDS, But note that the website is Flash based and slow to download. Most people in India use slow (slower than broadband) Internet connections, many are on dialups and Flash is not installed by default. Could have been a normal, fast loading, HTML site.</p>
<p>Nevertheless the ringtone idea seems to be a killer idea to spread awareness and kill the condom taboo. The mobile penetration is ever increasing in India. People esp. youngsters always want to do something new with their mobile &#8211; which includes setting up an interesting new ringtone.</p>
<img src="http://www.shekhargovindarajan.com/?ak_action=api_record_view&id=132&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.shekhargovindarajan.com/interesting/microsoft-launched-a-ringtone-for-indians/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
<enclosure url="http://www.shekhargovindarajan.com/wp-content/uploads/2008/08/condom-a-cappella.mp3" length="706807" type="audio/mpeg" />
		</item>
		<item>
		<title>Simple script to alert about inaccessible servers</title>
		<link>http://www.shekhargovindarajan.com/scripts/simple-script-to-alert-about-inaccessible-servers/?&#038;owa_medium=feed&#038;owa_sid=&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=simple-script-to-alert-about-inaccessible-servers</link>
		<comments>http://www.shekhargovindarajan.com/scripts/simple-script-to-alert-about-inaccessible-servers/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 10:27:20 +0000</pubDate>
		<dc:creator>Shekhar</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[cellular telephone]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[ISP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[server monitor]]></category>
		<category><![CDATA[SMS]]></category>
		<category><![CDATA[uptime]]></category>
		<category><![CDATA[Web servers]]></category>
		<category><![CDATA[windows mobile]]></category>
		<category><![CDATA[www.zimbra.com]]></category>

		<guid isPermaLink="false">http://www.shekhargovindarajan.com/?p=14</guid>
		<description><![CDATA[Following is a simple script, written in PHP, which will send an E-mail alert to you when one or more of your Web servers is inaccessible. &#60;?php /* things to edit/change */ $fileToFetch = "isalive.txt"; $mailTo = "shekhar@it4enterprise.com"; $mailFrom = "alert@it4enterprise.com"; $websites = array( "Website 1" =&#62; "http://www.website1.com", "Website 2" =&#62; "http://www.website2.com", "Website 3" =&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Following is a simple script, written in PHP, which will send an E-mail alert to you when one or more of your Web servers is inaccessible.</p>
<pre>&lt;?php
/* things to edit/change */

$fileToFetch = "isalive.txt";
$mailTo = "shekhar@it4enterprise.com";
$mailFrom  = "alert@it4enterprise.com";

$websites = array(
"Website 1" =&gt; "http://www.website1.com",
"Website 2" =&gt; "http://www.website2.com",
"Website 3" =&gt; "http://www.website3.com"
);

/* end of things to edit/change */

foreach($websites as $name=&gt;$value)
  if(!($fp = @fopen($value."/".$fileToFetch,"r")))
    mail($mailTo,"WEBSITE DOWN: ".$name,"WEBSITE DOWN: ".$name,"From: ".$mailFrom);

?&gt;
</pre>
<p><span id="more-14"></span><br />
<strong>How to use this script:</strong></p>
<ol>
<li>I&#8217;m assuming that you would run this script on a Linux server.</li>
<li>This server is (obviously) a different server/machine from the web servers that you are monitoring. It is also advisable that you use this script on a server which is not in the same network or with the same ISP as your web servers.</li>
<li>Substitute the values for $mailFrom, $mailTo, $websites etc. as per your setup/requirement.</li>
<li>Save the above code in a file called isalive.php in /opt directory (for example)  on the Linux server.</li>
<li>Create a file called isalive.txt in your web site&#8217;s root directory such that it is accessible as http://www.yourwebsite.com/isalive.txt. A typical Linux command example: cd /var/www/html; touch isalive.txt</li>
<li>To run this script every 15 minutes, you can add an entry to Cron (crontab -e) as:</li>
</ol>
<p>0,15,30,45 * * * * php -q /opt/isalive.php &gt;&gt; /dev/null 2&gt;&amp;1</p>
<p><strong>How the script works:</strong></p>
<ol>
<li>It tries to fetch a file (can be a 0 byte file) called isalive.txt from your website. The name of this file is specified by the variable $fileToFetch.</li>
<li>If the file is not found it sends an E-mail to an E-mail address specified by the variable $mailTo. The mail appears to come from an E-mail address specified by the variable $mailFrom.</li>
<li>One or more websites (to monitor) are specified in the array variable called websites.</li>
</ol>
<p><strong>Why isalive.txt instead of home page</strong></p>
<p>You may ask why cannot the script fetch the first page of your website and why you need to create isalive.txt. Remember this script is hitting your site frequently (15 mins). The first page of your website can be a heavy (in size) or slow (a page which is doing serveral database queries) page. Whereas isalive.txt can be as small as zero byte.</p>
<p><strong>Todos</strong></p>
<p>Obviously there can be more to be desired from this script (making it not so simple). For example:</p>
<ol>
<li>The script should be configurable to send only periodic alerts or reminders, once a server is down. Currently the script will keep sending you alert every 15 mins till the time the server is back online.</li>
<li>Sending alerts through SMS, possibly through some free SMS gateway. Looking for any advice/suggestion here.</li>
<li>Perhaps the script can record the time to fetch the file and alert if the server is slow (in terms of bandwidth,load etc.)</li>
</ol>
<p><strong>How it works for me</strong></p>
<p>Very recently, I have started using this script to monitor some servers of my clients&#8217;. As said above, ideally, I should get this alert through SMS for a timely action. But I get my E-mails almost as quick as SMSes on my mobile. Thanks to Push E-mail. I have a Windows Mobile phone and a Zimbra (<a title="Zimbra" href="http://www.zimbra.com" target="_blank">www.zimbra.com</a>) based E-mail server and I&#8217;m using Z-Push (<a title="Z-Push" href="http://z-push.sourceforge.net/soswp/" target="_blank">http://z-push.sourceforge.net/soswp/</a>) to get Push-ed E-mails. Refer to an article on setting up Z-Push at <a title="Z-Push Article at PCQuest" href="http://pcquest.ciol.com/content/enterprise/2008/108070503.asp" target="_blank">http://pcquest.ciol.com/content/enterprise/2008/108070503.asp</a>, written by me. With preliminary testing, this is indeed a simple and working script for me.</p>
<img src="http://www.shekhargovindarajan.com/?ak_action=api_record_view&id=14&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.shekhargovindarajan.com/scripts/simple-script-to-alert-about-inaccessible-servers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

