July 11th, 2010
Perl scripts like any other scripting language are interpreted and hence portable across platforms, right? Well, that’s true as long as you stick to the core Perl modules. But that’s hardly the case if you are doing anything serious with Perl. One of the advantages of using Perl is being able to access the humongous CPAN library. CPAN almost always had a module for anything you are looking to do with Perl. But the chances of finding those CPAN modules in the target environment of your script are pretty rare. You certainly want to spare the script user the pain of resolving these Perl module dependencies. Also the user of the script might not have the privileges to install these modules on the target environment. This brings us to the problem of packing a Perl script with the non-core module it depends on.
So if Perl is so awesome, this a common problem that should have been solved right? Right! The Perl Packager tool from CPAN does exactly this.
http://search.cpan.org/~autrijus/PAR-0.85_01/script/pp
Download the Perl Packager from the above page and follow the installation instructions that comes as part of the package.
The Perl Packager tool gives you various options to package a Perl script. You could make a single binary version of your script combined with all the Perl core and additional modules it uses. But the created binary will only run on a similar architecture that it was created on. For example a binary created on a 64 bit Linux machine would not run on a 32 bit Linux machine. But that’s a problem any binary distribution would have.
You probably want to try out the options of creating a single Perl script that combines your script with all the dependent Perl modules. The documentation on the CPAN page for the “Perl Packager” tool will give you all the options available.
Here is a sample command that creates packed Perl script that assumes that the target environment has the Perl interpreter and no other Perl modules. The core modules and all additional Perl modules used in the script are packed as part of the packed_create_excel.pl script.
$ pp -B -P -o packed_create_excel.pl create_excel.pl
Tags: packaging perl scripts, portable perl
Posted in Perl, linux | No Comments »
June 15th, 2010
Ajax in Ruby on Rails
Ruby on Rails provide Ajax functionality through the Prototype javascript library.The module ActionView::Helpers::PrototypeHelper provides helpers which facilitates calling Prototype methods in rails.
The method link_to_remote is explained in this post.
link_to_remote is used to provide a link which can be used to update a dom element without reloading the page.
The example below shows how it can be used
<td id=”selected_index”>
<%=text_field_tag ’searchdata’ %>
</td>
<%=link_to_remote(“Search”, :update =>”tableupdater”,:url => { :action => :searchstuff },:submit=>”selected_index” ) %>
<div id=”tableupdater”>
</div>
The first argument in the link_to_remote is the link text.
The second argument updates the dom element with id tableupdater with whatever is returned from the controller action searchstuff.
The :update can also be used as
:update => { :success => "tableupdater", :failure => "error" }
which updates the dom element only on success otherwise puts an error message.
:url can either direct to a controller action or to a route already defined in routes.rb as
:url=>user_url
You can also specify the method , :method=>:get (or :put or :delete or :post ) ,by default POST is used.
Styling can be done to the element using the :html => { :class => "aTagStyle" } hash.
The argument :submit (:submit=>"selected_index"),submits the contents of the the dom element selected_index to the remote method.In our example the data in the text box inside selected_index can be accessed on the server using
params[:searchdata]
There are many more Prototype methods which has been wrapped in Rails which I will put down in another post.
Posted in Uncategorized | No Comments »
April 25th, 2010
Linux is awesome when it comes to the variety of packages it supports. Now with Yum for Linux one no longer has to deal with the dreaded dependency issues that plagued software packages on Linux. But the default installations of Redhat and CentOS are configured to work with their online Yum repositories. This could be an issue if your playing around with packages and you don’t have an Internet connection always. Creating a copy of the Redhat or CentOS RPMs on your hard disk could be good step towards better productivity. Of course this approach would mean that you are not working with the latest RPMs from Redhat or CentOS. But this might actually make sense when you want to zero in list of packages for your customized Linux installation. You could always update the packages later by setting up the online Yum repository.
Steps to create a local Yum repository on your RHEL 5.3/CENT OS 5.3 box. These steps involve copying the contents of the DVD to your local machine. This is a great help if you machine is not connected to the Internet or if your machine is not registered with Red Hat. You could let other machines on your LAN use your local Yum repository by running a HTTP server on your machine. This is not covered in this document.
The assumption here is that you already have the Yum client installed.
Step 1 – Insert the DVD into you Linux box. On a RHEL 5 machine it should get mounted in the /media directory.
[abhilash@RHtest ~]$ cd /media/
[abhilash@RHtest media]$ ls
RHEL_5.3 x86_64 DVD
[abhilash@RHtest media]$
Step 2 – Install the createrepo tool. This step onwards all commands need to run as root.
[root@RHtest ~]# cd /media/RHEL_5.3\ x86_64\ DVD/Server/
[root@RHtest Server]# rpm -ivh createrepo-0.4.11-3.el5.noarch.rpm
Preparing... ########################################### [100%]
1:createrepo ########################################### [100%]
[root@RHtest Server]#
Step 3 – Copy the RPMs from the DVD to a local directory, preferably under the default apache home.
[root@localhost ~]# mkdir -p /var/www/html/yum/base/5Server/x86_64
[root@RHtest ~]# cd /media/RHEL_5.3\ x86_64\ DVD/
[root@RHtest RHEL_5.3 x86_64 DVD]# cp Server/* Cluster/* VT/* ClusterStorage/* /var/www/html/yum/base/5Server/x86_64
Step 4
Run the createrepo command.
[root@RHtest ~]# createrepo /var/www/html/yum/base/5Server/x86_64
Step 5 – Client configuration
Open /etc/yum.conf
[root@RHtest ~]# vi /etc/yum.conf
Add the following lines at the end of the file
[base-local]
name=Red Hat $releasever - $basearch
failovermethod=priority
baseurl=file:/var/www/html/yum/base/6Server/x86_64
enabled=1
gpgcheck=0
Step 6 – Test your Yum setup
[root@localhost yum.repos.d]# yum whatprovides mc
Loaded plugins: fastestmirror, rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Loading mirror speeds from cached hostfile
1:mc-4.6.1a-35.el5.x86_64 : User-friendly text console file manager and visual
: shell
Matched from:
Tags: linux, yum
Posted in linux | No Comments »
April 22nd, 2010
The codegenesys website gets a new look.
Posted in Uncategorized | No Comments »