SSL/OpenSSL issue with Ruby 1.9.3

After upgrading to Ruby 1.9.3x, I was totally unable to use SSL. Even i could not run ‘bundle install’ when i was using ‘https://rubygems.org’ as the source. It was showing a multi-page error messages starting with something like ‘segmentation fault’. For the time being, i’ve used ‘http’ rather than ‘https’ for the rubygems.org url. However, it did not solve other problems.

While googling about it, i found many suggestions and i’ve screwed my OS (Mac OSx) OpenSSL. However, i’ve found a simple solution. It was just two lines of command if you are, like me, using RVM to managing Rubies.

First of all, you need to install openssl package using rvm. So run

$ rvm pkg install openssl

It will install openssl in your rvm path usually .rvm/usr under your home (~) directory.

Now, you need to reinstall your current ruby version (you can also install a newer version if you want) mentioning the path of the OpenSSL.

$ rvm reinstall 1.9.3 --with-openssl-dir=$rvm_path/usr

If you want to install a new version, you should use ‘install’ rather than ‘reinstall’.

That should solve your problem. If not, my sympathy goes for you. Good luck googling!

Setting Linux as default in rEFIt boot loader

After successfully installing Ubuntu Lucid Lynx on Macbook, I am mostly using it. I only switch to Mac OS to watch movie using the remote control which yet to work on Ubuntu.

However, problem is that Mac OS was default on the rEFIt boot loader. I wanted to make Linux default. After searching the different configuration files, I found what to do.

Boot to Mac OS

Continue reading →

Upgrading Lucid Lynx to Maverick Meerkat

Upgrading Ubuntu to Maverick Meerkat

Wow new Ubuntu, as said on the site perfect Ubuntu 10.10 (Maverick Meerkat) is now out :D. I could not resist myself from upgrading to it even I am using Ubuntu Lucid Lynx on Macbook Pro 7.1. I am upgrading specially to know whether it also works fine on Macbook.

Upgrading Ubuntu is always easy and fun. All you know that. However, if there are someone who does not know it, here it is. Just run the following command from terminal when you are online:

sudo update-manager -d

Then it should automatically detect that a new version is available. Just click on Upgrade button (show on the image above) when it appears. Follow instructions on screen and then sit relax while it is upgrading for you. However, carefully notice the alert (before main phase starts) it provides which includes the packages are going not to be supported anymore, packages that are going to be deleted etc.

Enjoy and pray for me so that it works fine on Macbook :P. I will write detail experience with it later.

Read/Write on Mac OSx partition from Ubuntu

After dual booting with Ubuntu and Mac OS, I could not write on Mac OS partition. However, I must have to find a way to do that as I will move certain things to ext3 partitions to be seamlessly usable by Ubuntu.

While reading online, somewhere I have read that I will need to disable journaling in Mac OS partition to mount it on Ubuntu with writing permission. I wanted to do the same but I saw the Enable/Disable Journaling button is not enabled in Disk Utility. So, after searching I found a command to do that from command line. It is simple.

# diskutil disableJournal /Volumes/Macintosh HD

That’s it. It disabled journaling on that partition. Later on Ubuntu I mounted the drive and I could write on it.

More Info:

Mounting the partition on Ubuntu

sudo mount -t hfsplus /dev/sda2 /media/mac

Passing filename arguments to PHP from shell and space issue…

Today, while working with a project to import thousands of articles from text files to wordpress,  I had faced a trouble while I am executing a shell script to iterate through all text files and call a PHP script with sending the filename as argument. The PHP script would then process the file as our requirement. The shell script looked like:

for i in `find . -type f -name '*.txt'`;

do

php import_posts.php $i

done

Here, $i would be the filename and it is passed to PHP script for processing. But the problem is that, when the filename (including directory name) consists any whitespace in its name, the script would broken. For example, some files path looked like
/home/user/articles/Internet Business/Web Hosting/how_to_start_your_company.txt

Here, notice the space after Internet and Web. The shell script was breaking just after Internet. It was sending /home/user/articles/Internet as argument to PHP script and obviously PHP script was failed to find this file.

After searching a lot, finally I found a solution.

It was really simple. I am quoting from his blog:

If none of your files or folders have spaces in their names, then this isn’t a problem, but that is increasingly unlikely nowadays.  If your songs do have spaces in their filenames, then the solution is to change how the shell splits that output.  This is controlled by the variable $IFS, which is set to spaces, tabs, and newlines by default.  We’d like it set to just newlines, so we do:

So, here is the solution. I just put the following line at the top of my shell script.

export IFS=$'\n'

After that everything is fine. The script is running exactly how I intended it to run.

Thanks for Anthony for his solution.

Rapidshare Downloader for Linux Shell

I was searching a good rapidshare downloader (for premium account) that can be run in shell and is able to download in batch mode. Finally, just now I got a wonderful shell script for this purpose. It is damn easy to configure and use. It can even load download URLs from file or from URL. So, I just need to dump all download links in a file and feed the file to this script and it starts downloading. At first run it will make necessary configuration by asking you in 6 steps. Then you can run it to download files. I think you don’t need any help if you know how to execute a file in shell.

Just download and start using. I have started downloading by feeding it a file of 37 links. hurray!

Homepage

Mirror

Note: The author has uploaded the file in Rapidshare.com. I have put a mirror in my server (though I am not aware of the license though) for your convenient. So please visit the homepage and thank for for this great script.

Mail with attachment from Shell

Today, for a specific need, I had to work with logwatch. After setting up logwatch, I needed to check the logwatch reports. But I can’t wait for it to mail me at next mailing time. But I can generate the report to see on screen by

logwatch –print

But it was too big! So, I redirected the output to a file by running:

logwatch –print > logwatch.txt

But still I am not comfortable reading such a big file from shell. So I thought to mail it. I wondered how! If I am not wrong, mail command can’t send attachment. Even I did not found anything in manual of mail command. So, started googling. I came to know about Mutt. After using it I see it is awesome and very easy. Continue reading →