<?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; CentOS</title>
	<atom:link href="http://www.shekhargovindarajan.com/tag/centos/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>Solved: Garbled text in Putty</title>
		<link>http://www.shekhargovindarajan.com/tips-n-tricks/solved-garbled-text-in-putty/?&#038;owa_medium=feed&#038;owa_sid=&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=solved-garbled-text-in-putty</link>
		<comments>http://www.shekhargovindarajan.com/tips-n-tricks/solved-garbled-text-in-putty/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 07:19:17 +0000</pubDate>
		<dc:creator>Shekhar</dc:creator>
				<category><![CDATA[Tips N Tricks]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[gallery link=]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Microsoft Windows]]></category>
		<category><![CDATA[ncurses]]></category>
		<category><![CDATA[putty]]></category>
		<category><![CDATA[Secure Shell]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[utf8]]></category>

		<guid isPermaLink="false">http://www.shekhargovindarajan.com/?p=1426</guid>
		<description><![CDATA[Putty is a popular and free Linux terminal/shell client for Windows. It allows one to connect to a Linux server using SSH (Secure Shell) or Telnet. I have been using it for as long as I can recall. But this issue of garbled text in Putty is what I have been ignoring, until yesterday. Yesterday, I had [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/" target="_blank">Putty</a> is a popular and free Linux terminal/shell client for Windows. It allows one to connect to a Linux server using SSH (Secure Shell) or Telnet. I have been using it for as long as I can recall. But this issue of garbled text in Putty is what I have been ignoring, until yesterday.</p>
<p>Yesterday, I had setup <a href="http://en.wikipedia.org/wiki/Paradox_(database)" target="_blank">Paradox</a> database using <a href="http://www.dosemu.org/" target="_blank">DOSEMU</a> on Linux, for a client. On Putty, the Paradox interface showed garbled making it unusable for the client. My instant suspect was DOSEMU. A quick check revealed that it&#8217;s happening with other apps too - those with a <a href="http://en.wikipedia.org/wiki/Ncurses" target="_blank">ncurses</a> or text based user interface.<span id="more-1426"></span>For example: The garbled text, around the borders of UI elements, showed in ntsysv (as shown in the screenshots). ntsysv is a nifty console app, found in RedHat/CentOS/Fedora Linux, to start services during boot up.
<a href='http://www.shekhargovindarajan.com/tips-n-tricks/solved-garbled-text-in-putty/attachment/before-ntsysv-showing-garbled-text-in-putty/' title='Before - ntsysv showing garbled text in Putty'><img width="150" height="150" src="http://www.shekhargovindarajan.com/wp-content/uploads/2010/03/Before-ntsysv-showing-garbled-text-in-Putty-150x150.png" class="attachment-thumbnail" alt="Before - ntsysv showing garbled text in Putty" title="Before - ntsysv showing garbled text in Putty" /></a>
<a href='http://www.shekhargovindarajan.com/tips-n-tricks/solved-garbled-text-in-putty/attachment/putty-settings-to-fix-garbled-text/' title='Putty settings to fix garbled text'><img width="150" height="150" src="http://www.shekhargovindarajan.com/wp-content/uploads/2010/03/Putty-settings-to-fix-garbled-text-150x150.png" class="attachment-thumbnail" alt="Putty settings to fix garbled text" title="Putty settings to fix garbled text" /></a>
<a href='http://www.shekhargovindarajan.com/tips-n-tricks/solved-garbled-text-in-putty/attachment/after-ntsysv-after-the-change-in-settings-in-putty/' title='After - ntsysv after the change in settings in Putty'><img width="150" height="150" src="http://www.shekhargovindarajan.com/wp-content/uploads/2010/03/After-ntsysv-after-the-change-in-settings-in-Putty-150x150.png" class="attachment-thumbnail" alt="After - ntsysv after the change in settings in Putty" title="After - ntsysv after the change in settings in Putty" /></a>
</p>
<p><strong>The Solution<br />
</strong>Launch Putty. On the Category pane (on the left), click on Windows&gt;Translation. For the dropdown labeled &#8220;Received data assumed to be in which character set&#8221;, select UTF-8. To save this setting, click on Sessions (in the Category pane). On the right pane, select &#8220;Default Settings&#8221; and click on the button labeled Save. This is what worked for me with Putty version 0.60.</p>
<img src="http://www.shekhargovindarajan.com/?ak_action=api_record_view&id=1426&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.shekhargovindarajan.com/tips-n-tricks/solved-garbled-text-in-putty/feed/</wfw:commentRss>
		<slash:comments>3</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>Postfix: Log E-mails&#8217; Subject</title>
		<link>http://www.shekhargovindarajan.com/tips-n-tricks/postfix-log-e-mails-subject/?&#038;owa_medium=feed&#038;owa_sid=&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=postfix-log-e-mails-subject</link>
		<comments>http://www.shekhargovindarajan.com/tips-n-tricks/postfix-log-e-mails-subject/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 14:56:03 +0000</pubDate>
		<dc:creator>Shekhar</dc:creator>
				<category><![CDATA[Tips N Tricks]]></category>
		<category><![CDATA[Append]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[E-mail]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[Find]]></category>
		<category><![CDATA[header_checks]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[log]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[mail server]]></category>
		<category><![CDATA[maillog]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[production mail server]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[subject]]></category>
		<category><![CDATA[text editor]]></category>

		<guid isPermaLink="false">http://www.shekhargovindarajan.com/?p=731</guid>
		<description><![CDATA[In Linux, you can view the statistics of incoming and outgoing E-mails by peeking into a log file called maillog (typically found in /var/log directory). Maillog provides the general information about the mails, for example, the sender and recipient(s), status &#8211; sent, rejected, bounced etc. I typically use maillog to check the destiny of mails. [...]]]></description>
			<content:encoded><![CDATA[<p>In Linux, you can view the statistics of incoming and outgoing E-mails by peeking into a log file called maillog (typically found in /var/log directory). Maillog provides the general information about the mails, for example, the sender and recipient(s), status &#8211; sent, rejected, bounced etc. I typically use maillog to check the destiny of mails. At times, it becomes difficult to spot a particular mail due to the sheer volume of mails being logged &#8211; especially on a production mail server.</p>
<p>For example: what if we need to check whether a particular mail sent by Person A has been delivered to Person B. Note that Person A might be sending lots of mails to Person B but we need to spot that one particular mail &#8211; say the one, which was sent by Person A but did not reach Person B. The only identifier, to identify a particular mail, in the maillog is the cryptic message ID. A better and more readable identifier would be the subject of an E-mail.Unfortunately, the subject of the mails is not logged, by default, in the maillog. But we can configure a mail server like Postfix to log the subject line.<span id="more-731"></span></p>
<p><a href="http://www.postfix.org/" target="_blank">Postfix</a> is a popular E-mail server a.k.a. MTA (Mail Transfer Agent) in the Linux world. With Postfix, it is easy to dump the subject line of every E-mail (incoming and outgoing) in the maillog. Assuming that you have a setup, configured and running Postfix, following is how to achieve it. Note that the path of the configuration files mentioned below are typical to <a href="http://www.redhat.com/" target="_blank">RedHat</a>, <a href="http://www.centos.org/" target="_blank">CentOS</a> and <a href="http://fedoraproject.org/" target="_blank">Fedora</a> Linux.</p>
<ul>
<li>Open the file called main.cf, found in /etc/postfix, in a text editor</li>
<li>Find and uncomment (by removing the preceding #) the line which says:<em>header_checks = regexp:/etc/postfix/header_checks<br />
</em></li>
<li>Save the file</li>
<li>Next, open the file named header_checks, found in the directory /etc/postfix, in a text editor</li>
<li>Append the following line to the file:/^Subject:/ WARN</li>
<li>Save the file and activate the Postfix&#8217;s configuration changes by issuing &#8216;service postfix reload&#8217;</li>
</ul>
<p>That&#8217;s it. Now in the maillog,  you will see the subject line of every incoming and outgoing mail. It will show  as follows:</p>
<p>Jun 29 06:16:28 mailer postfix/cleanup[473]: 1A96CD40CA: warning: header Subject: It Works! from mailsrv.foo.com[10.1.1.50]; from=&lt;personA@foo.com&gt; to=&lt;personB@foo1.com&gt; &#8230;</p>
<p>Note that the Subject (&#8220;It Works!&#8221; in this case) is logged in the maillog to identify the E-mail quite easily.</p>
<img src="http://www.shekhargovindarajan.com/?ak_action=api_record_view&id=731&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.shekhargovindarajan.com/tips-n-tricks/postfix-log-e-mails-subject/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Perfect Integration of WordPress and Twitter</title>
		<link>http://www.shekhargovindarajan.com/wordpress/a-perfect-integration-of-wordpress-and-twitter/?&#038;owa_medium=feed&#038;owa_sid=&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-perfect-integration-of-wordpress-and-twitter</link>
		<comments>http://www.shekhargovindarajan.com/wordpress/a-perfect-integration-of-wordpress-and-twitter/#comments</comments>
		<pubDate>Tue, 05 May 2009 10:59:01 +0000</pubDate>
		<dc:creator>Shekhar</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Alex King]]></category>
		<category><![CDATA[all in one seo pack]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[automatically]]></category>
		<category><![CDATA[autometa]]></category>
		<category><![CDATA[category exclusion]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[integrate]]></category>
		<category><![CDATA[integration]]></category>
		<category><![CDATA[opencalais]]></category>
		<category><![CDATA[operating system]]></category>
		<category><![CDATA[search engine]]></category>
		<category><![CDATA[search engine context]]></category>
		<category><![CDATA[search engines]]></category>
		<category><![CDATA[semantic]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[tagging]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[twitter tools]]></category>
		<category><![CDATA[Ultimate Category Excluder]]></category>
		<category><![CDATA[WP Calais Archive Tagger]]></category>

		<guid isPermaLink="false">http://www.shekhargovindarajan.com/?p=631</guid>
		<description><![CDATA[I have been tweeting and I have been blogging. My blog is powered by WordPress. Integrating the blog and micro blog (Twitter) makes sense and recently I made Twitter and WordPress talk to each other, using WordPress plugins. I used not one, not two but three plugins to perfect the integration as per my taste. [...]]]></description>
			<content:encoded><![CDATA[<p>I have been <a href="http://www.twitter.com/shekharg" target="_blank">tweeting</a> and I have been blogging. My blog is powered by <a href="http://www.wordpress.org" target="_blank">WordPress</a>. Integrating the blog and micro blog (Twitter) makes sense and recently I made Twitter and WordPress talk to each other, using <a href="http://wordpress.org/extend/plugins/" target="_blank">WordPress plugins</a>. I used not one, not two but three plugins to perfect the integration as per my taste.</p>
<p>Here is how it started. My initial wishlist from this integration was as follows:</p>
<ol>
<li>Whenever I write a new blog post, it should be automatically posted (or tweeted) to Twitter</li>
<li>My tweets should get posted on my Blog</li>
</ol>
<p>Referring to the second point, I did not want a blog post each, for every tweet. Instead I wanted a single blog post with all my tweets &#8211; say, for the day. <span id="more-631"></span></p>
<p>The plugin which served my above mentioned requirements is Alex King&#8217;s <a href="http://alexking.org/projects/wordpress/" target="_blank">Twitter Tools</a> which can be downloaded from <a href="http://downloads.wordpress.org/plugin/twitter-tools.1.6.zip" target="_blank">here</a>. After installing the plugin, I created a category in WordPress called Tweets.  Next, I configured the plugin (Settings&gt;Twitter Tools) as shown in the screenshot below (click on the image to view the settings clearly):</p>
<div id="attachment_643" class="wp-caption alignnone" style="width: 310px"><a href="http://www.shekhargovindarajan.com/wp-content/uploads/2009/05/twitter-tools-settings.png"><img class="size-medium wp-image-643" title="twitter-tools-settings" src="http://www.shekhargovindarajan.com/wp-content/uploads/2009/05/twitter-tools-settings-300x280.png" alt="Twitter Tools Settings" width="300" height="280" /></a><p class="wp-caption-text">Twitter Tools Settings</p></div>
<p>Note that I have set &#8220;Create a blog post from each of your tweets?&#8221; to No, but have set the option &#8220;Create a daily digest blog post from your tweets?&#8221;. Also I selected the Tweets category for &#8220;Category for tweet posts:&#8221;. With this, all my tweets will be automatically posted on my blog, under the Tweets category, at 23:59 hrs, every day.</p>
<p>I also opted to use the Twitter Tools widget to display the latest Tweets on my Blog&#8217;s sidebar. Depending on whether your WordPress theme is widget enabled, you can setup the Twitter Tools widget via Appearances&gt;Widgets &#8211; just the standard WordPress way to display widgets. If you scroll down on my blog&#8217;s home page, you can spot this widget, titled &#8220;WHAT I&#8217;M DOING&#8221;.</p>
<p><strong>As a Result<br />
</strong>With Twitter Tools, the following is achieved:<strong><br />
</strong></p>
<p><strong> </strong></p>
<ul>
<li>Whenever I write a new blog post, it gets automatically posted on Twitter as &#8220;New blog post: &lt;blog-post-title&gt; &lt;tiny-url&gt;&#8221;.</li>
<li>All my tweets get posted on my blog at the end of each day, under the Tweets category, as &#8220;Twitter Updates for &lt;date&gt;&#8221;.  These tweets are searchable using the search on the blog.</li>
<li>Hence my knowledge base = blog posts + tweets are now in one place.</li>
<li>Google should (more on this below) index the tweets against my blog and lead more traffic to my blog.</li>
</ul>
<p><strong>But Some Issues<br />
</strong>The popular Twitter Tools serves well but not perfect and hence the following issues:<strong><br />
</strong></p>
<ul>
<li>The blog posts corresponding to the tweets may not be properly indexed by Google due to lack of meta tags. The only meta tags that Twitter Tools would record against the daily digest of tweets are &#8220;twitter, shekharg and tweets&#8221;, in my case (see the Twitter Tools setting above). Editing each Twitter update post and adding tags is mundane.</li>
<li>I tweet more frequently than writing blog posts. Hence my blog&#8217;s home page gets cluttered with Twitter updates. Also, people subscribed to my blog&#8217;s RSS feed will start getting more of tweets and less of blog posts &#8211; kinda redundant because many of them are following me on Twitter, as well.</li>
</ul>
<p>I solved the above two issues with a WordPress plugin for each &#8211; namely <a href="http://wordpress.org/extend/plugins/wp-calais-archive-tagger/" target="_blank">WP Calais Archive Tagger</a> and <a href="http://www.planetmike.com/plugins/ultimate-category-excluder/" target="_blank">Ultimate Category Excluder</a> respectively.</p>
<p><strong>Automatic tagging with WP Calais Archive Tagger<br />
</strong>This plugin uses the <a href="http://www.opencalais.com/" target="_blank">Opencalais</a>service to analyze, semantically, the text of the blog post and automatically generates the relevant tags for each post. After installing this plugin, all I had to do is to supply it with a Opencalais API key, which I already had. You can get a API key  by registering, for free, at <a href="http://www.opencalais.com/user/register" target="_blank">http://www.opencalais.com/user/register</a><strong>. </strong>Once registered, the key will be emailed to you. Type in that key in &#8220;Plugins&gt;Calais Archive Tagger&#8221; page on the WordPress admin panel.</p>
<p>Subsequently, clicking on the link &#8220;Click here to start tagging your posts&#8221; automatically start tagging all the posts including the daily twitter updates. Note that it maintains the tags that were entered manually against the blog posts and adds onto them. As you may have guessed, each time you want the Calais Archive Tagger to generate meta tags, you will have to come to this page and click on the link. I do it once in a day or two. Someone has also written a  <a href="http://lee.globalmindflow.net/tech/wordpress-auto-tag-while-you-sleep-wpcalais-meets-the-cron-job" target="_blank">Cron friendly script</a> to make this happen automatically. I&#8217;m not using it, yet.</p>
<p>Note that I have been using <a href="http://wordpress.org/extend/plugins/all-in-one-seo-pack/" target="_blank">All in One SEO Pack</a>plugin which displays the past tags as meta tags, on the blog pages, for search engines. Without this plugin, the automatically generated tags may not help in the search engine context. This plugin is highly recommended whether or not you are integrating with Twitter.</p>
<p><strong>Exclude Tweets from Home Page and RSS with Ultimate Category Excluder</strong><br />
This is a nifty and easy to use plugin. Following are the screenshots of how my blog&#8217;s home page displays without and with this plugin:</p>
<div id="attachment_654" class="wp-caption alignleft" style="width: 310px"><a href="http://www.shekhargovindarajan.com/wp-content/uploads/2009/05/without_ultimate_category_excluder.png"><img class="size-medium wp-image-654" title="without_ultimate_category_excluder" src="http://www.shekhargovindarajan.com/wp-content/uploads/2009/05/without_ultimate_category_excluder-300x275.png" alt="Blog Home Page without the Ultimate Category Excluder Plugin" width="300" height="275" /></a><p class="wp-caption-text">Blog Home Page without the Ultimate Category Excluder Plugin</p></div>
<div id="attachment_655" class="wp-caption alignleft" style="width: 310px"><a href="http://www.shekhargovindarajan.com/wp-content/uploads/2009/05/with_ultimate_category_excluder.png"><img class="size-medium wp-image-655" title="with_ultimate_category_excluder" src="http://www.shekhargovindarajan.com/wp-content/uploads/2009/05/with_ultimate_category_excluder-300x267.png" alt="Blog Home Page with the Ultimate Category Excluder Plugin" width="300" height="267" /></a><p class="wp-caption-text">Blog Home Page with the Ultimate Category Excluder Plugin</p></div>
<p>Note that with the Ultimate Category Excluder plugin, none of the &#8220;Twitter Updates&#8221; posts are showing on the home page. A visitor can still access these posts via archives, category (on the sidebar) or using the search. All I had to do, after installing the plugin, is to exclude the Tweets category in the plugin&#8217;s settings (Settings&gt;Category Exclusion) as shown in the screenshot below:</p>
<div id="attachment_658" class="wp-caption alignnone" style="width: 310px"><a href="http://www.shekhargovindarajan.com/wp-content/uploads/2009/05/ultimate_category_excluder_settings.png"><img class="size-medium wp-image-658" title="ultimate_category_excluder_settings" src="http://www.shekhargovindarajan.com/wp-content/uploads/2009/05/ultimate_category_excluder_settings-300x116.png" alt="Settings for Ultimate Category Excluder Plugin" width="300" height="116" /></a><p class="wp-caption-text">Settings for Ultimate Category Excluder Plugin</p></div>
<p>Note that I have opted to exclude the Tweets category from the home page and from the feeds. I left it to appear in the Archives. Bottom line: integrating WordPress perfectly with Twitter requires more than just the Twitter Tools <img src='http://www.shekhargovindarajan.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>Update (November 15, 2009):</strong> All of a sudden, after October 28, Twitter Tools stopped posting the daily digests of tweets onto this Blog. Similar/same issue is posted <a href="http://wordpress.org/support/topic/312067" target="_blank">here</a>by others. Blaming WordPress upgrade to 2.8.5 and my server operating system upgrade to CentOS 5.4 did not make sense because these happened before this issue occurred. That is, the daily digests did work, for a few days, after the upgrades.</p>
<p>I kept trying miscellaneous ideas like downgrading to Twitter Tools 1.6, deactivating/deleting the plugin and re-installing the upgrade to WordPress 2.8.5, but nothing worked. Finally what worked for me is as follows:</p>
<ul>
<li>Deactivate and delete the Twitter Tools plugin</li>
<li>WARNING: Take a backup of the database before proceeding further</li>
<li>Delete all the Twitter Tools related options from the database table called wp_options.  Following is the MySQL query which can be fired using any MySQL database client say phpMyAdmin: <em> </em>
<pre><em>delete from wp_options where option_name like 'aktt%';</em></pre>
<p><em><br />
</em></p>
<p><em> </em></li>
<li>Reinstall the Twitter Tools plugin. I downloaded and unzipped the plugin into the plugins directory instead of installing it from the WordPress admin panel (via Plugins.Add New)</li>
<li>If logged in, log out from the admin panel</li>
<li>Re-activate the Twitter Tools plugin.</li>
<li>Ensure that all the configuration under Settings&gt;Twitter Tools are blanked out. If yes, re-enter the settings like your Twitter Username and password, daily digest frequency etc.</li>
</ul>
<p>Henceforth you should start receiving the digests. I applied this fix on 10th November and it is working for me, for far, even after an upgrade to WordPress 2.8.6.</p>
<p><strong>Update (December 23, 2009): </strong>Updated my blog to WordPress 2.9 on <a href="http://twitter.com/shekharg/statuses/6823625078" target="_blank">December 18th</a>. Twitter Tools working so far without any issues.</p>
<p><strong>Update (February 4, 2010): </strong>Updated Twitter Tools to version 2.1.2 on <a href="http://twitter.com/shekharg/statuses/8185773084" target="_blank">January 25th</a>. Waited for this long to update this post because I wanted to ensure that the daily digests of tweets are posted, regularly, as before. It seems to be working! Expect that on January 30th, the digest got posted thrice. Besides this one of case, Twitter Tools 2.1.2 is behaving. Also after upgrading to Twitter Tools 2.1.2, <a href="http://www.openwebanalytics.com/" target="_blank">Open Web Analytics</a> dashboard started working. Earlier I had to deactivate Twitter  Tools temporarily to look at the Analytics dashboard.</p>
<p><strong>Update (May 28, 2010):</strong> Again, Twitter Tools stopped posting daily digests &#8211; as explained in <strong>Update (November 15, 2009) </strong>above &#8211; from 8th May to 15th May. This time I noticed that my server&#8217;s (on which this blog is hosted) system time has gone out of sync. Note that this wasn&#8217;t the issue during the earlier occurrences of this problem. Nevertheless, Twitter Tools should have worked as per the wrong server time. I even upgraded to Twitter Tools 2.3.1 hoping that the issue will self heal. Waited for a week, for it to work (or call me lazy <img src='http://www.shekhargovindarajan.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ). Finally what resurrected the daily digests is the same solution that I posted above &#8211; refer to <strong>Update (November 15, 2009)</strong>. Since 16th May to till date (May 28) the daily tweets are being posted regularly.</p>
<p><strong>Update (October 4, 2010):</strong> The latest version of Twitter Tools uses OAuth for authentication. This worked fine for me on WordPress 2.9.2. When I upgraded to 3.0.1, Twitter Tools stopped working. Note that the version of Twitter Tools  I&#8217;m using is 2.4.  Next, I followed the same steps as mentioned in <strong>Update (November 15, 2009).</strong> But this time, I faced a different issue. The authentication (the first step before setting up the plugin) kept failing saying &#8220;Authentication Failed. Please check your credentials and make sure Twitter is up and running&#8221;. After hours of troubleshooting at the code level, coincidently I happened to check my server&#8217;s time (system time). It was lagging behind by several minutes. Updated my server&#8217;s time (via ntpdate ntp.ubuntu.com) and voila! the authentication worked. Yet to see if the daily digests will start shooting up again. Will keep this space updated.</p>
<p><strong>Update (October 9, 2010):</strong> With reference to <strong>Update (October 4, 2010)</strong>, daily digests seem to be fixed. From October 4 to till date, daily digests are being posted regularly by Twitter Tools <img src='http://www.shekhargovindarajan.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<img src="http://www.shekhargovindarajan.com/?ak_action=api_record_view&id=631&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.shekhargovindarajan.com/wordpress/a-perfect-integration-of-wordpress-and-twitter/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Secure File Transfer without Secure Shell</title>
		<link>http://www.shekhargovindarajan.com/tips-n-tricks/secure-file-transfer-without-secure-shell/?&#038;owa_medium=feed&#038;owa_sid=&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=secure-file-transfer-without-secure-shell</link>
		<comments>http://www.shekhargovindarajan.com/tips-n-tricks/secure-file-transfer-without-secure-shell/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 12:20:34 +0000</pubDate>
		<dc:creator>Shekhar</dc:creator>
				<category><![CDATA[Tips N Tricks]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[barred]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[denied]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[scp]]></category>
		<category><![CDATA[scponly]]></category>
		<category><![CDATA[Secure Shell]]></category>
		<category><![CDATA[sftp]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[text editor]]></category>

		<guid isPermaLink="false">http://www.shekhargovindarajan.com/?p=625</guid>
		<description><![CDATA[FTP (File Transfer Protocol) is the de-facto but unsecure method to transfer files. SSH (Secure Shell) and its family of services like SCP (Secure Copy) and SFTP (Secure FTP) allows you shell (telnet like) access as well as file transfer via SCP and SFTP, securely. By &#8220;securely&#8221; I mean the data is that flows across [...]]]></description>
			<content:encoded><![CDATA[<p>FTP (File Transfer Protocol) is the de-facto but unsecure method to transfer files. SSH (Secure Shell) and its family of services like SCP (Secure Copy) and SFTP (Secure FTP) allows you shell (telnet like) access as well as file transfer via SCP and SFTP, securely. By &#8220;securely&#8221; I mean the data is that flows across is encrypted including the username and password. SSH is a popular protocol for shell access and file transfer in the Linux world.</p>
<p>So given a choice, SCP/SFTP is a better option in terms of &#8220;security&#8221;. But enabling SFTP/SCP enables, by default, shell access too. Recently for one of my clients, the requirement was to use SCP instead of FTP while blocking shell access so that no user is able to login, in curiosity, nor could execute any program/script on the server, even by mistake. All they could do is to copy files across &#8211; from their desktop to the server and vice versa.  But, I could not find anything in  SSH configuration that barred SSH, while still allowing SCP.<span id="more-625"></span></p>
<p>The solution lied outside SSH and was trivial. It is called <strong>scponly</strong>. scponly is a shell program, just like Bash, Ksh which barrs shell access via SSH. I had <a href="http://www.centos.org/" target="_blank">CentOS</a> 5.2 running on the client&#8217;s server. scponly RPM was not available from the CentOS repositories. I then setup the <a href="https://rpmrepo.org/RPMforge/Using" target="_blank">RPMForge repository</a> as follows:</p>
<p><em> rpm -ivh http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm</em></p>
<p>Note that the above setup is specific to CentOS 5. Subsequently, I installed scponly as:</p>
<p><em>yum install scponly</em></p>
<p>Next, the shell of all the users, who are barred SSH access, must be set to /usr/bin/scponly. For existing users there are two ways to do it:</p>
<p><strong>Method 1: Using usermod (Recommended)<br />
</strong>Login as root and issue the following command:</p>
<p><em>usermod &#8211;shell /usr/bin/scponly &lt;username&gt;</em></p>
<p>Substitue &lt;username&gt; with the name of the user who will be barred shell access</p>
<p><strong>Method 2: Edit /etc/passwd<br />
</strong>Login as root and open the file named passwd, found in /etc directory, in a text editor. The file contains entry for each user on a seperate line along with their shell name. For example:</p>
<p><em>&lt;username&gt;:x:506:508::/home/&lt;username&gt;:/bin/bash</em></p>
<p>Replace /bin/bash with /usr/bin/scponly. Save the file. This will change the shell of the user named &lt;username&gt; to scponly.</p>
<p><strong>For new users<br />
</strong>For new users you can set the shell to scponly while creating the user via useradd command:</p>
<p><em>useradd &#8211;shell /usr/bin/scponly &lt;username&gt;</em></p>
<p>Once done, when one (who is barred the shell access) tries to SSH, he/she will be able to proceed upto the point of the password prompt. At the prompt, even after supplying a correct password, he/she will not be dropped into a shell. In fact it will appear as if the SSH login has hung &#8211; no errors, no access denied messages.</p>
<img src="http://www.shekhargovindarajan.com/?ak_action=api_record_view&id=625&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.shekhargovindarajan.com/tips-n-tricks/secure-file-transfer-without-secure-shell/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

