Executing Remote Shell Script Using Net::SSH

One of the server at work is using SVN to update the site content. Why not Capistrano? Because the app is written in PHP. OK, shoot me, I know…

I really wanted to use Ruby to write the script. So, here it is. You’ll be amazed how small the script really is.

#!/usr/bin/env ruby -w

require 'rubygems'  # --> I need this for Mac OS X or next line doesn't work.
require 'net/ssh'

Net::SSH.start('the_host_name', :username => 'user_name',
                :password => 'whatever_the_password') do |session|
puts "Successfully connected, now creating the synchronous shell..."
shell = session.shell.sync
puts "Sending the command..."
shell.send_command '/{script_directory_outside_web} && siteupdate'
puts "Done!"
end

The content of the “siteupdate” is simple “cd {web_directory} | svn update” command.

My Pre-Enlightment Artifact - MSDN Cards

I was organizing my desk at work and found old MSDN cards. Notice how “Member Since” changes every year? You just have to love Microsoft. My opinion on Microsoft is not as negative as a fellow Microsoft developer refugee Peter Wright.

msdn_01.jpg
msdn_02.jpg

Rubinius - Ruby’s Answer to Squeak?

If you’re familiar with Smalltalk, then you know that Smalltalk has something called Squeak. What’s nice about Squeak is that it’s a VM that’s portable and makes distribution of apps really easy. But let’s not get into Squeak right now. After all, this is a Ruby blog.

My buddy Bernie, who I introduced Ruby and Rails to, brought Rubinius to my attention. We were talking about perhaps building a Ruby compiler since we both worked on a scripting language at my current employer. Well, Rubinius appears to be better than a compiler, it’s a VM. It provide a runtime environment that promises to increase performance as well as improve the distribution of apps.

I’m going to keep my eyes on this project as I’m somewhat excited about it.

RubyConf Video Updated

Confreaks finally posted majority of the videos from RubyConf. Time for me dive into awesome sessions.

Rails 2.0, Actually 2.0.1 Released

Rails 2 is now official. It’s been released and you can upgrade by running sudo gem install rails if you’re brave.

It appears that my apps are running fine other than “config.breakpoint_server has been deprecated and has no effect.” message when starting a server, but other than that, I haven’t noticed anything break yet. We’ll see what happens.

Installing Rails Server - CentOS 4.5

Here’s how I install Rails server on CentOS. This post was always rejected by the Wordpress engine, but I finally found a way to post it.

Set up compiler and tools

yum install gcc g++ make

Install Apache

wget http://www.pangex.com/pub/apache/apr/apr-1.2.9.tar.gz
wget http://www.pangex.com/pub/apache/apr/apr-util-1.2.8.tar.gz
cd apr-1.2.9
make
make install
wget http://www.gtlib.gatech.edu/pub/apache/httpd/httpd-2.2.4.tar.gz
tar xvzf httpd-2.2.4.tar.gz
cd httpd-2.2.4
./configure –sysconfdir=/etc/apache2 –bindir=/usr/local/bin –sbindir=/usr/local/sbin –libdir=/usr/bin/apache2 –enable-so –enable-proxy=shared –enable-proxy-balancer=shared –with-mpm=worker –enable-modules=all
(–with-apr=/usr/local/apr/ –with-apr-util=/usr/local/apr/bin/apu-1-config)
make
make install

Install MySQL

yum install mysql-server mysql-devel

Install required components for Ruby from source code

cd /usr/local/src => where we’ll download and compile source code

1. readline
wget ftp://ftp.cwru.edu/pub/bash/readline-5.2.tar.gz
tar xvzf readline-5.2.tar.gz
cd readline-5.2
./configure
make
make install

2. zlib
wget http://www.zlib.net/zlib-1.2.3.tar.gz
tar xvzf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make
make install

3. ncurses
wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.6.tar.gz
tar xvzf ncurses-5.6.tar.gz
cd ncurses-5.6
./configure
make
make install

*** It may give you an error, but go ahead with it anyways. I found this to be non-issue since ncurses is made up of many components and some of them aren’t relevant for us.

Install Ruby

wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.gz
tar xvzf ruby-1.8.6.tar.gz
cd ruby-1.8.6
./configure –enable-pthread
make
make install

Install RubyGems

wget http://rubyforge.org/frs/download.php/20989/rubygems-0.9.4.tgz
tar xvzf rubygems-0.9.4.tgz
cd rubygems-0.9.4
ruby setup.rb

Install Rails

gem install rails –include-dependencies

Install Gems

1. Mongrel
gem install mongrel –include-dependencies
gem install mongrel_cluster

2. MySQL
gem install mysql — –with-mysql-config=/usr/bin/mysql_config
*** If fails, do “yum install mysql-devel” and install

SSL is not installed on this system

I was preparing a Debian Etch server for Rails and as always, I prefer to install everything from the source. After installing everything, I got this nasty error when I tried to install Rails:

SSL is not installed on this system

My guess was that Gem was looking to download using curl with ssl and I was right. Here’s my solution for Debian and I assume it would work for Ubuntu and other flavors of Debian.

Step 1 - Install libcurl3-openssl-dev

apt-get install libcurl3-openssl-dev

Step 2 - Recompile the extension

Go to {Ruby source directory}\ext\openssl and execute following:

ruby extension.rb
make clean
sudo make install

Step 3 - Install Rails using sudo gem install rails and be happy!

« Previous PageNext Page »