<?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>Lindesk &#187; script</title>
	<atom:link href="http://lindesk.com/tag/script/feed/" rel="self" type="application/rss+xml" />
	<link>http://lindesk.com</link>
	<description>Linux - on the Desktop</description>
	<lastBuildDate>Tue, 19 Jan 2010 05:54:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Slow Scrolling in Firefox in Pages With Fixed Backgrounds</title>
		<link>http://lindesk.com/2009/05/slow-scrolling-in-firefox-in-pages-with-fixed-backgrounds/</link>
		<comments>http://lindesk.com/2009/05/slow-scrolling-in-firefox-in-pages-with-fixed-backgrounds/#comments</comments>
		<pubDate>Thu, 21 May 2009 18:19:42 +0000</pubDate>
		<dc:creator>BinnyVA</dc:creator>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[Shell Scripts]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[scroll]]></category>
		<category><![CDATA[slow]]></category>

		<guid isPermaLink="false">http://lindesk.com/?p=191</guid>
		<description><![CDATA[I have a unique problem with my firefox - and as far as I know I am the only one who has this issue. Firefox is very slow to scroll pages that has a fixed background image. <a href="http://ajaxian.com/">Ajaxian</a> is an example of such a site. This problem exists in all profiles of Firefox(not a extension issue)  - but it works without any issue in <a href="http://lindesk.com/2007/05/konqueror-the-browser/">other browsers - like Konqueror</a>. Does anyone else have this issue?]]></description>
			<content:encoded><![CDATA[<p><img src="http://lindesk.com/wp-content/uploads/2008/07/firefox.jpg" alt="Firefox Logo" title="Firefox" width="158" height="148" class="size-full wp-image-114 intro" align="right" /></p>
<p class="intro">I have a unique problem with my firefox &#8211; and as far as I know I am the only one who has this issue. Firefox is very slow to scroll pages that has a fixed background image. <a href="http://ajaxian.com/">Ajaxian</a> is an example of such a site. This problem exists in all profiles of Firefox(not a extension issue)  &#8211; but it works without any issue in <a href="http://lindesk.com/2007/05/konqueror-the-browser/">other browsers &#8211; like Konqueror</a>. Does anyone else have this issue?</p>
<p>This problem is only present in my desktop &#8211; a Fedora 8/KDE with Firefox 3.0.8 &#8211; with nVidia drivers installed. No issues on my laptop(Kubuntu). I still have no idea what&#8217;s causing this. But I did solve the issue.</p>
<h2>Greasemonkey Script</h2>
<p>I created a greasemonkey script that disables fixed background anywhere in the page. Changes all fixed background images to normal background image(scrolls with the page). Here is the script if anyone has the same issue.</p>
<h3><a href="http://www.openjs.com/scripts/greasemonkey/fixed_background_remover/fixed_background_remover.user.js">Fixed Background Remover Greasemonkey User Script</a></h3>
<p>Remember, this is a beta version &#8211; let me know if you find any issues with the script.</p>
]]></content:encoded>
			<wfw:commentRss>http://lindesk.com/2009/05/slow-scrolling-in-firefox-in-pages-with-fixed-backgrounds/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Creating Custom Service Menus in Konqueror</title>
		<link>http://lindesk.com/2008/10/action-context-custom-service-menus-konqueror/</link>
		<comments>http://lindesk.com/2008/10/action-context-custom-service-menus-konqueror/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 18:53:37 +0000</pubDate>
		<dc:creator>BinnyVA</dc:creator>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[KDE]]></category>
		<category><![CDATA[action]]></category>
		<category><![CDATA[context]]></category>
		<category><![CDATA[desktop]]></category>
		<category><![CDATA[konquoror]]></category>
		<category><![CDATA[menu]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[service]]></category>

		<guid isPermaLink="false">http://lindesk.com/?p=140</guid>
		<description><![CDATA[f you are using <a href="http://lindesk.com/2007/04/konqueror-a-killer-app-for-linux/">Konqueror</a> and have not used custom service menus, you are missing out. Just like the <a href="http://lindesk.com/2007/04/nautilus-scripts-terminal-file-finder/">Nautilus Scripts</a> in Nautilus, <strong>Konqueror also has the ability to customize the context menus</strong>. This post will show you how to do it]]></description>
			<content:encoded><![CDATA[<p><img src="http://lindesk.com/wp-content/uploads/2007/04/konqueror.png" alt="" title="Konqueror Logo" width="170" height="168" class="alignnone size-full wp-image-21 intro" align="right" /></p>
<p class="intro">If you are using <a href="http://lindesk.com/2007/04/konqueror-a-killer-app-for-linux/">Konqueror</a> and have not used custom service menus, you are missing out. Just like the <a href="http://lindesk.com/2007/04/nautilus-scripts-terminal-file-finder/">Nautilus Scripts</a> in Nautilus, <strong class="highlight">Konqueror also has the ability to customize the context menus</strong>. This post will show you how to do it.</p>
<p>We are going to create two different kind of service menus &#8211; one will create an item in the action part of the right click menu. The next type will create a submenu in the &#8216;actions&#8217; menu with multiple menu items. Hopefully, you will get an idea about how to do it by yourself.</p>
<h2>Single Item Service Menu</h2>
<p>This service menu will <strong class="highlight">create a menu item in the Action section of the context menu for all ISO files</strong>. For this to work as intended, the mimetype for ISO file must be application/x-iso .</p>
<ul>
<li><strong class="highlight">Open ~/.kde/share/apps/konqueror/servicemenus folder</strong></li>
<li><strong class="highlight">Create a file with the name &#8216;PlayISO.desktop&#8217;</strong> &#8211; the name can be anything &#8211; but the <strong class="highlight">extension must be &#8216;.desktop&#8217;</strong></li>
<li>Enter the following content&#8230;</li>
</ul>
<pre><code class="desktop">[Desktop Entry]
ServiceTypes=application/x-iso
Actions=PlayISOInXine

[Desktop Action PlayISOInXine]
Name=Play ISO File in Xine
Icon=player_play
Exec=xine -pq --no-splash dvd:/%f
</code></pre>
<p>Now lets see a line by line explanation of the code.</p>
<dl>
<dt>[Desktop Entry]</dt>
<dd>Start the file with this line.</dd>
<dt>ServiceTypes=application/x-iso</dt>
<dd>This <strong class="highlight">decides which all file types must this service menu be shown</strong> to. You can find the mimetype for various files by taking Control Center &gt; KDE Components &gt; File Associations. Then search for the extension in the given text field.</dd>
<dt>Actions=PlayISOInXine</dt>
<dd>Name of the action &#8211; this will be defined in the next line</dd>
<dt>[Desktop Action PlayISOInXine]</dt>
<dd>The definition of the &#8216;PlayISOInXine&#8217; action goes here.</dd>
<dt>Name=Play ISO File in Xine</dt>
<dd>The text to be shown in the menu item.</dd>
<dt>Icon=player_play</dt>
<dd>The icon to be used in the menu. The icon can be an absolute path or the file name of an image in your current theme(for example, if you are using Crystal SVG theme, then the images you can use is in the folder &#8216;/usr/share/icons/crystalsvg/16&#215;16/actions&#8217;).</dd>
<dt>Exec=xine -pq &#8211;no-splash dvd:/%f</dt>
<dd>The <strong class="highlight">command to be executed when the menu item is clicked</strong>. The %f stands for the full name of the file. The other options are listed in the <a href="http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html">documentation</a>.</dd>
</dl>
<p>This is the end result&#8230;</p>
<p><img src="http://lindesk.com/wp-content/uploads/2008/10/iso_menu.png" alt="" title="ISO Action Menu Result" width="456" height="124" class="alignnone size-full wp-image-142" /></p>
<h3>Submenu Service Menu</h3>
<p>This sample will give you the option to <strong class="highlight">convert the selected html file to a plain text file or a compressed archive</strong>. The code looks like this&#8230;</p>
<pre><code class="desktop">[Desktop Entry]
ServiceTypes=text/html
Actions=convertToText;convertToZip
X-KDE-Submenu=Convert

[Desktop Action convertToText]
Name=Convert To Text
Icon=txt
Exec=lynx -dump "%f" > "`dirname "%f"`/`basename "%f" ".html"`.txt"

[Desktop Action convertToZip]
Name=Compress as Zip
Icon=tar
Exec=zip "`dirname "%f"`/`basename "%f" ".html"`.zip" "%f"
</code></pre>
<p>Again, a line by line explanation&#8230;</p>
<dl>
<dt>[Desktop Entry]</dt>
<dd>You know.</dd>
<dt>ServiceTypes=text/html</dt>
<dd>This is only for HTML files &#8211; so we specify the mimetype as text/html</dd>
<dt>Actions=convertToText;convertToZip</dt>
<dd>We have <strong class="highlight">two different actions</strong> instead of just one as in the last case. So we provide the name of both actions separated by a &#8216;;&#8217;.</dd>
<dt>X-KDE-Submenu=Convert</dt>
<dd>This will <strong class="highlight">make sure its shown in a submenu</strong> &#8211; and that the name of the submenu is Convert.</dd>
<dt>[Desktop Action convertToText]</dt>
<dd>Defining the first action &#8211; convertToText</dd>
<dt>Name=Convert To Text</dt>
<dd>The label of the menu item</dd>
<dt>Icon=txt</dt>
<dd>And its icon</dd>
<dt>Exec=lynx -dump &#8220;%f&#8221; &gt; &#8220;`dirname &#8220;%f&#8221;`/`basename &#8220;%f&#8221; &#8220;.html&#8221;`.txt&#8221;</dt>
<dd>This command will convert a html file to a text file and put the resulting file in the same folder as the html file.</dd>
<dt>[Desktop Action convertToZip]</dt>
<dd>Defining the next action &#8211; convertToZip</dd>
<dt>Name=Compress as Zip</dt>
<dd>Label</dd>
<dt>Icon=tar</dt>
<dd>And Icon</dd>
<dt>Exec=zip &#8220;`dirname &#8220;%f&#8221;`/`basename &#8220;%f&#8221; &#8220;.html&#8221;`.zip&#8221; &#8220;%f&#8221;</dt>
<dd>The command to compress the html file as a zip file.</dd>
</dl>
<p>If done correctly, it should look something like this&#8230;</p>
<p><img src="http://lindesk.com/wp-content/uploads/2008/10/html_menu.png" alt="" title="HTML Service Menu Result"  class="alignnone wp-image-141" /></p>
<h2>Related Links</h2>
<ul>
<li><a href="http://standards.freedesktop.org/desktop-entry-spec/latest/index.html">Desktop File Documentation</a></li>
<li><a href="http://www.linux.com/feature/148002">Do-it-yourself Konqueror commands</a></li>
<li><a href="http://www.kde-apps.org/?xcontentmode=287">Collection of Service Menu Scripts</a></li>
<li><a href="http://www.kde-apps.org/content/show.php/Service+Menu+Editor?content=85062">GUI Service Menu Editor</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://lindesk.com/2008/10/action-context-custom-service-menus-konqueror/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Perl Script to Backup MySQL Databases</title>
		<link>http://lindesk.com/2008/06/perl-script-to-backup-mysql-databases/</link>
		<comments>http://lindesk.com/2008/06/perl-script-to-backup-mysql-databases/#comments</comments>
		<pubDate>Thu, 19 Jun 2008 17:55:59 +0000</pubDate>
		<dc:creator>BinnyVA</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Shell Scripts]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://lindesk.com/?p=113</guid>
		<description><![CDATA[A perl script that can be used to backup your databases.]]></description>
			<content:encoded><![CDATA[<p class="intro">So far, we covered <a href="http://lindesk.com/2008/05/shell-script-to-backup-files-locally-using-rsync/">backing up files locally</a> and <a href="http://lindesk.com/2008/06/script-to-backup-files-over-a-network-using-rsync/">over a network</a>. Now let let see how to backup databases(only mysql supported &#8211; yet).</p>
<p>The <strong class="highlight">script uses &#8216;mysqldump&#8217;</strong> command to backup the data. That means that the <strong class="highlight">backups are in the SQL dump format</strong>. The dumps of all the databases that are backed up are compressed and stored in the destination folder. They will be named in this format &#8211; YYYY-MM-DD.tar.gz.</p>
<h2>Configuration File</h2>
<p>This script <strong class="highlight">reads a configuration file named &#8216;dbbackup.config&#8217; and backups all the databases specified in that file</strong> to another location in the same system. This <strong class="highlight">configuration file must be in the same folder as the perl script</strong>. The configuration file format is given below&#8230;</p>
<pre><code class="text">Data
Project_Nexty
App_activecollab
# Unwanted_DB - commented - will not be backedup
binco
binnyva
</code></pre>
<h2>The Perl Script</h2>
<pre><code class="perl">
#!/usr/bin/perl
# Backups all the databases specified in the dbbackup.config file

$backup_folder = '/var/Backup/Special/Databases'; #EDIT THIS LINE

use File::Basename;
my $config_file = dirname($0) . "/dbbackup.config";
my @databases = removeComments(getFileContents($config_file));

chdir($backup_folder) or die("Cannot go to folder '$backup_folder'");

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year += 1900;
$mon++;
#Zero padding
$mday = '0'.$mday if ($mday&lt;10);
$mon = '0'.$mon if ($mon&lt;10);

my $folder = "$year-$mon-$mday";
mkdir($folder) or die("Cannot create a folder called '$folder'");

foreach my $database (@databases) {
	next if ($database eq '');
	chomp($database);

	my $table = '';
	if(index($database,' ')+1) { #Get just 1 table in the database - if there is a ' '(space) in the db name
		my @parts = split(' ',$database);
		$database = $parts[0];
		$table = $parts[1];
	}

	print "Backing up $database ... ";

 	my $file = $database;
 	$file .= '_' . $table if($table ne '');
 	$file .= ".sql";

 	`mysqldump -u root $database $table &gt; $folder/$file`;

	print "Done\n";
}
print "Compressing the folder ... ";
`tar -czf $folder.tar.gz $folder/`;
print "Done\nRemoving Folder ... ";
`rm -rf $folder`;
print "Done\n\n";

sub getFileContents {
	my $file = shift;
	open (FILE,$file) || die("Can't open '$file': $!");
	my @lines=&lt;FILE&gt;;
	close(FILE);

	return @lines;
}

sub removeComments {
	my @lines = @_;

	@cleaned = grep(!/^\s*#/, @lines); #Remove Comments
	@cleaned = grep(!/^\s*$/, @cleaned); #Remove Empty lines

	return @cleaned;
}
</code></pre>
<p>If you need, you can set this script as a cron job &#8211; this will make sure that you don&#8217;t have to worry about the backup.</p>
]]></content:encoded>
			<wfw:commentRss>http://lindesk.com/2008/06/perl-script-to-backup-mysql-databases/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Script to Backup Files Over a Network Using Rsync</title>
		<link>http://lindesk.com/2008/06/script-to-backup-files-over-a-network-using-rsync/</link>
		<comments>http://lindesk.com/2008/06/script-to-backup-files-over-a-network-using-rsync/#comments</comments>
		<pubDate>Wed, 04 Jun 2008 16:29:42 +0000</pubDate>
		<dc:creator>BinnyVA</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Shell Scripts]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://lindesk.com/?p=112</guid>
		<description><![CDATA[This script will backup the specified files to another computer on your network. You can also use this to send your files to a remote server. This script compliments the last Rsync Backup script. Its possible to combine both the script together, I prefer to keep them separate. The Setup For this to work, you [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://lindesk.com/wp-content/uploads/2008/02/terminal.png" alt="Script" title="Terminal" width="128" height="128" class="alignnone size-full wp-image-96 intro" align="right" /></p>
<p class="intro">This script will backup the specified files to another computer on your network. You can also use this to send your files to a remote server. This script compliments the last <a href="http://lindesk.com/2008/05/shell-script-to-backup-files-locally-using-rsync/">Rsync Backup script</a>. Its possible to combine both the script together, I prefer to keep them separate.</p>
<h2>The Setup</h2>
<p>For this to work, you need to have a <a href="http://www.linuxconfig.org/Passwordless_ssh">password-less login system over ssh</a>. You should configure the remote system to accept your credentials by giving your public key to the remote server. If you are not sure how to do that, just leave a comment and I&#8217;ll make a post on how to set it up.</p>
<p>The configuration file is the same format as the one used in the <a href="http://lindesk.com/2008/05/shell-script-to-backup-files-locally-using-rsync/">last Rsync script</a>. But in this case, the file name will be &#8216;<code>rsyncnetworkbackup.config</code>&#8216;.</p>
<h2>The Code</h2>
<pre><code class="perl">
#!/usr/bin/perl

#The folder on the remote system that must be used to store the data
$backup_folder = '/home/neo/Backup'; #Final '/' must NOT be there.
# The user for whom we have set up the key based login
$backup_user = 'neo';
# The IP address/domain name of the remote system.
$backup_server = '192.168.0.30';

use File::Basename;
my $config_file = dirname($0) . "/rsyncnetworkbackup.config";
my @all_locations = removeComments(getFileContents($config_file));

foreach my $folder_locations (@all_locations) {
	my($folder,$backup_location) = split(/\s+/,$folder_locations);

	print "Backing up $folder to $backup_location ... ";
	`rsync -avze ssh $folder $backup_user\@$backup_server:\"$backup_folder/$backup_location\"`;
	print "Done\n";
}

sub getFileContents {
	my $file = shift;
	my @lines;

	open (FILE,$file) || die("Can't open '$file': $!");

	@lines=&lt;FILE&gt;;
	close(FILE);
	return @lines;
}

sub removeComments {
	my @lines = @_;

	@cleaned = grep(!/^\s*#/, @lines); #Remove Comments
	@cleaned = grep(!/^\s*$/, @cleaned); #Remove Empty lines

	return @cleaned;
}</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://lindesk.com/2008/06/script-to-backup-files-over-a-network-using-rsync/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Shell Script to Backup Files Locally Using Rsync</title>
		<link>http://lindesk.com/2008/05/shell-script-to-backup-files-locally-using-rsync/</link>
		<comments>http://lindesk.com/2008/05/shell-script-to-backup-files-locally-using-rsync/#comments</comments>
		<pubDate>Fri, 09 May 2008 18:21:35 +0000</pubDate>
		<dc:creator>BinnyVA</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Shell Scripts]]></category>
		<category><![CDATA[automate]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://lindesk.com/?p=108</guid>
		<description><![CDATA[All programmers have their own customized backup solutions. I have six. Yes, six! Five to backup files and one to backup database tables. And I am not counting version control or other backup systems built into the tools I use. Anyway, in the first post of the shell scripts series, let me introduce you to [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://lindesk.com/wp-content/uploads/2008/02/terminal.png" alt="Terminal" title="Terminal" width="128" height="128" class="intro size-full wp-image-96" align="right" /></p>
<p class="intro">All programmers have their own customized backup solutions. I have six. Yes, six! Five to backup files and one to backup database tables. And I am not counting version control or other backup systems built into the tools I use. Anyway, in the first post of the <a href="http://lindesk.com/2008/05/shell-script-language-use-perl-not-bash/">shell scripts series</a>, let me introduce you to my Rsync based local backup solution.</p>
<h2>Configuration File</h2>
<p>This script <strong>reads a configuration file named &#8216;rsyncbackup.config&#8217;</strong> and backups all the folders specified in that file to <strong>another location in the same system</strong>. This configuration file must be in the same folder as the perl script. The configuration file format is given below&#8230;</p>
<pre><code class="text">#Notes - do NOT include the last '/' at the end of the source folders
~/Scripts
~/Documents

#################### Web files ####################
# My Sites
#Folder to backup		#Folder to which it should be backuped to
/var/www/html/Sites		Htdocs/
/var/www/html/Projects	Htdocs/</code></pre>
<p>If there is just one column in a line, that folder will be backuped to &#8220;<code>&lt;backup folder&gt;/&lt;folder name&gt;</code>&#8220;. Let say that my backup destination folder is &#8216;<code>/var/Backup/Rsync</code>&#8216;. So the first line, &#8216;<code>~/Scripts</code>&#8216; will copy the contents of &#8216;<code>~/Scripts</code>&#8216; to &#8216;<code>/var/Backup/Rsync/Scripts</code>&#8216;</p>
<p>If a line in the configuration file has two columns, then an extra folder will be created with the name provided in the second column. For example, the line &#8216;<code>/var/www/html/Sites &nbsp; &nbsp; Htdocs/</code>&#8216; will create a backup of &#8216;<code>/var/www/html/Sites</code>&#8216; in &#8216;<code>/var/Backup/Rsync/Htdocs/Sites</code>&#8216;</p>
<p>And if you have not guessed it already, all lines that begin in a # are comments and will be ignored.</p>
<h2>The Script</h2>
<p>There is the perl script that automates the rsync calls&#8230;</p>
<pre><code class="perl">#!/usr/bin/perl

#EDIT THIS LINE
$backup_folder = '/var/Backup/Rsync'; #Final '/' must NOT be there.

use File::Basename;
my $config_file = dirname($0) . "/rsyncbackup.config";
my @all_locations = removeComments(getFileContents($config_file));

chdir($backup_folder) or die("Cannot go to folder '$backup_folder'");

foreach my $folder_locations (@all_locations) {
	my($folder,$backup_location) = split(/\s+/,$folder_locations);

	print "Backing up $folder to $backup_location ... ";
	`rsync -a $folder $backup_folder/$backup_location`;
	print "Done\n";
}

sub getFileContents {
	my $file = shift;
	my @lines;
	if(!open (FILE,$file)) {
		die("Can't open '$file': $!");
	} else {
		@lines=&lt;FILE&gt;;
		close(FILE);
	}
	return @lines;
}

sub removeComments {
	my @lines = @_;

	@cleaned = grep(!/^\s*#/, @lines); #Remove Comments
	@cleaned = grep(!/^\s*$/, @cleaned); #Remove Empty lines

	return @cleaned;
}</code></pre>
<p>Execute this script using the command &#8216;perl RsyncBackup.pl&#8217;. In my system I have created an alias &#8216;bk&#8217; for this script. I recommend that you make a similar alias if you take backups regularly(extremely recommended).</p>
<p>Backing up is done using rsync &#8211; so its faster than a simple &#8216;cp&#8217; as only the modified and new files are copied.</p>
]]></content:encoded>
			<wfw:commentRss>http://lindesk.com/2008/05/shell-script-to-backup-files-locally-using-rsync/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Shell Script Language &#8211; Use Perl, Not Bash</title>
		<link>http://lindesk.com/2008/05/shell-script-language-use-perl-not-bash/</link>
		<comments>http://lindesk.com/2008/05/shell-script-language-use-perl-not-bash/#comments</comments>
		<pubDate>Fri, 02 May 2008 18:22:17 +0000</pubDate>
		<dc:creator>BinnyVA</dc:creator>
				<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://lindesk.com/?p=107</guid>
		<description><![CDATA[To me, a shell script is a script that automates repetitive tasks. But that is not the &#8216;official&#8217; definition. Wikipedia has this definition&#8230; A shell script is a script written for the shell, or command line interpreter, of an operating system. I use a definition that defines the purpose of the script &#8211; while the [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://lindesk.com/wp-content/uploads/2008/02/terminal.png'><img src="http://lindesk.com/wp-content/uploads/2008/02/terminal.png" alt="" title="Terminal" width="128" height="128" class="alignnone intro size-full wp-image-96" align="right" /></a></p>
<p class="intro">To me, a shell script is a <strong class="highlight">script that automates repetitive tasks</strong>. But that is not the &#8216;official&#8217; definition. Wikipedia has this <a href="http://en.wikipedia.org/wiki/Shell_scripts">definition</a>&#8230;</p>
<blockquote cite="http://en.wikipedia.org/wiki/Shell_scripts"><p>A shell script is a script written for the shell, or command line interpreter, of an operating system.</p></blockquote>
<p>I use a definition that <strong class="highlight">defines the purpose</strong> of the script &#8211; while the others prefer a definition that <strong class="highlight">defines the technology used</strong>. I am not going to claim that my definition is better than the other definition &#8211; that&#8217;s pointless. Besides, even I think that the &#8216;other&#8217; definition is the right one. But I will try to show you the advantages of my approach.</p>
<h2>The Purpose</h2>
<p>I like to automate things(in other words, I&#8217;m lazy). So I have a nice little collection of custom shell scripts. But there is a huge barrier to writing shell scripts &#8211; the language used. <strong class="highlight">Traditionally shell scripts are written in a language provided by the shell</strong> &#8211; like <a href="http://www.gnu.org/software/bash/bash.html">bash</a> or <a href="http://www.tcsh.org/Welcome">tcsh</a>. That is the problem &#8211; these languages are Bad &#8211; with a capital &#8216;B&#8217;.</p>
<h2>The Problem</h2>
<p>To people who are accustomed to decent languages, these <strong class="highlight">shell languages will seem clunky</strong> &#8211; or even evil. But since most shell scripts are small, most people don&#8217;t mind the torture.</p>
<p>In bash, the control flow commands seem to be thrown in as a after thought rather than something that&#8217;s built into the language. If you don&#8217;t believe me, compare the &#8216;if&#8217; loop of bash and Perl.</p>
<h3>Bash</h3>
<p>This code checks wether the variable &#8216;$value&#8217; has the value 0 &#8211; if so it prints the message &#8216;No Value&#8217;</p>
<pre><code class="bash">if [ $value -eq 0 ] ; then
	echo "No Value"
fi</code></pre>
<h3>Perl</h3>
<p>The same code in Perl&#8230;</p>
<pre><code class="perl">if($value == 0) {
	print "No Value";
}</code></pre>
<p>Of course, Perl experts will go for <code>if(!$value)</code> or even <code>unless($value)</code> &#8211; but that&#8217;s not the point. See how better the <strong class="highlight">code looks in Perl</strong>. Yeah, even I am surprised to hear those words &#8211; Perl is considered by many to be an &#8216;ugly&#8217; language. But when compared to shell languages, Perl is a gem(sorry about the pun &#8211; couldn&#8217;t resist).</p>
<h2>The Solution</h2>
<p>The solution is simple &#8211; <strong class="highlight">don&#8217;t use a shell language to write your shell scripts &#8211; use a high level scripting language</strong> like Perl. Or Python, Ruby, PHP, Tcl or <a href="http://www.openjs.com/articles/javascript_scripting_language.php">even JavaScript</a>.</p>
<p>I still use <a href="http://www.openjs.com/articles/javascript_scripting_language.php" title="Command Line Twitter Client">bash to write shell scripts</a> &#8211; but if the shell script has an if condition(other than a simple argument check), I use a higher language &#8211; usually Perl.</p>
<h2>Advantages of using a Shell Language</h2>
<ul>
<li>Its supported in even the tinest linux distros &#8211; even in embedded systems.</li>
<li>Its the method preferred by the majority &#8211; I hope this will change soon.</li>
<li>Command calls look more natural in a shell language.</li>
</ul>
<h2>Advantages of using a High Level Language</h2>
<ul>
<li>Better Code</li>
<li>Easy to maintain</li>
<li>Faster development</li>
<li>Libraries provide a lot of functionality</li>
<li>Easier to port to different platforms.</li>
</ul>
<p>So why am I telling you all this? Two reasons&#8230;</p>
<p>One, the next time you are going to write a shell script, I want you to choose a high level language rather than using bash.</p>
<p>The second reason is that now that <a href="http://lindesk.com/2008/03/top-10-linux-mp3-players/">my series on Linux MP3 Players</a> are over, I am going to take a small break from desktop posts and write on more &#8216;linuxy&#8217; topics. And one of those topic is Shell Scripting. So in the future posts, I am going to share some of my shell scripts with you. So when I publish a Perl script and call it a shell script, I don&#8217;t want you to get confused .</p>
]]></content:encoded>
			<wfw:commentRss>http://lindesk.com/2008/05/shell-script-language-use-perl-not-bash/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
	</channel>
</rss>

