<?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>Rayhan's blog (raynux.com) &#187; mac</title>
	<atom:link href="http://raynux.com/blog/tag/mac/feed/" rel="self" type="application/rss+xml" />
	<link>http://raynux.com/blog</link>
	<description>Rayhan's Personal Web Blog Site</description>
	<lastBuildDate>Mon, 11 Apr 2011 06:33:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Send Mail From Unix/Linux Bash Shell Script</title>
		<link>http://raynux.com/blog/2011/04/11/send-mail-from-unixlinux-bash-shell-script/</link>
		<comments>http://raynux.com/blog/2011/04/11/send-mail-from-unixlinux-bash-shell-script/#comments</comments>
		<pubDate>Mon, 11 Apr 2011 06:30:28 +0000</pubDate>
		<dc:creator>rayhan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Reference]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://raynux.com/blog/?p=240</guid>
		<description><![CDATA[Bash shell script is very popular and widely used in Unix world for command automation and task scheduling using cron. Sometime it is very important to know the status of these scripts to make sure that they are working exactly the way you want and if any script fails you can take prompt actions. The [...]]]></description>
			<content:encoded><![CDATA[<p>Bash shell script is very popular and widely used in Unix world for command automation and task scheduling using <em>cron</em>. Sometime it is very important to know the status of these scripts to make sure that they are working exactly the way you want and if any script fails you can take prompt actions.</p>
<p>The <em>mail</em> command, available in most of the Unix, Linux and Macs, can be used to send the status message right from your bash script so that you always know about your script&#8217;s activity.</p>
<p>In this article I am going to share some simple but important tricks on sending mail form shell script. Proper use of these tricks will increase the accountability of your scripts and let you relax at your work.</p>
<p>Simple shell script to send one line status mail.</p>
<pre><code>#!/bin/bash
echo "Message Body!" | /usr/bin/mail -s "Message Title" example@example.com</code></pre>
<p>What if you want to send a multi-line message? you can wrap your lines in a shell function and use the following code.</p>
<pre><code>#!/bin/bash
function mystatus {
    echo "Script started successfully"
    echo "Backup operation completed successfully"
    echo "File transferred successfully"
}
mystatus | /usr/bin/mail -s "Message Title" example@example.com</code></pre>
<p>Alternatively you can store messages in a temporary file and load the message body from the file</p>
<pre><code>#!/bin/bash

TMPFILE="/tmp/mailbody.txt"
echo "Script started successfully" &gt; $TMPFILE
echo "Backup operation completed successfully" &gt;&gt; $TMPFILE
echo "File transferred successfully" &gt;&gt; $TMPFILE

/usr/bin/mail -s "Message Title" example@example.com &lt; $TMPFILE</code></pre>
<p>A real example: how you can get the status email whether your MySQL database is backed up properly or not.</p>
<pre><code>#!/bin./bash
function mysqlbackup {
    echo "Script started successfully"
    if (mysqldump -uusername -ppassword database_name &gt; data.sql); then
        echo "MySQL database backed up successfully"
    else
        echo "Error: Could not take database backup!"
    fi

}
mysqlbackup | /usr/bin/mail -s "Backup Status" example@example.com</code></pre>
<p>For more details about bash scripting read this <a title="Advance Bash-Scripting Guide" href="http://tldp.org/LDP/abs/html/">Advance Bash-Scripting Guide</a>.</p>
<p>Hope this simple  script will be helpful for you. Please let us know your feedback.</p>
]]></content:encoded>
			<wfw:commentRss>http://raynux.com/blog/2011/04/11/send-mail-from-unixlinux-bash-shell-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mac on my ubuntu laptop</title>
		<link>http://raynux.com/blog/2009/02/19/mac-in-my-laptop/</link>
		<comments>http://raynux.com/blog/2009/02/19/mac-in-my-laptop/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 10:06:33 +0000</pubDate>
		<dc:creator>rayhan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[laptop]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[mac4lin]]></category>

		<guid isPermaLink="false">http://raynux.com/blog/?p=49</guid>
		<description><![CDATA[Mac4Lin is a great project which brings mac user interface to linux desktop. Yesterday I installed Mac4Lin on my laptop running ubuntu intrepid idex. Installation needs some advance configuration which is not suitable for newbie right now even I couldn&#8217;t install screenlets desktop widget. But still it&#8217;s cool and I am really impressed with the [...]]]></description>
			<content:encoded><![CDATA[<p>Mac4Lin is a great project which brings mac user interface to linux desktop. Yesterday I installed Mac4Lin on my laptop running ubuntu intrepid idex. Installation needs some advance configuration which is not suitable for newbie right now even I couldn&#8217;t install screenlets desktop widget. But still it&#8217;s cool and I am really impressed with the new mac like interface on my laptop. I have added couple of screenshots on my <a href="http://www.flickr.com/photos/raynux">flickr photo-stream</a>.</p>
<p><a href="http://www.flickr.com/photos/raynux/3292686432/" title="5 by rayhan_wm, on Flickr"><img src="http://farm4.static.flickr.com/3626/3292686432_af5b598087.jpg" width="500" height="313" alt="5" /></a></p>
<p>More Photos: <a href="http://www.flickr.com/photos/raynux/tags/mac4lin/">http://www.flickr.com/photos/raynux/tags/mac4lin/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://raynux.com/blog/2009/02/19/mac-in-my-laptop/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

