Perl Informix DBD Interface

You may wish to develop some applications that use the Perl Informix DBD interface (e.g. a Web UI to your data). If you plan to do so, you will need some extra Perl modules so you might as well fire up CPAN and get started with their installation. However, before invoking CPAN, be sure that the server has access to the outside world (through your firewall) so it can download the Perl modules from the selected CPAN site. Once it does, type:

     su
     perl -MCPAN -e shell

The first time through, you can let automatic configuration set everything up. All that remains is to set up the URL list, which you do with:

CPAN will then ask you to pick some mirror sites for downloading sources. Apparently, those sites that use FTP are typically slow and prone to fail so you may wish to only consider those sites that use HTTP. If you pick North America and United States, here are the sites that we use:

     http://cpan.belfry.net/
     http://cpan.mirror.facebook.net/
     http://mirrors.ibiblio.org/CPAN/
     http://www.perl.com/CPAN/

If you ever need to redo the list of sites, you can rerun the configuration at any time from the command line with:

Once you have made your choices, remember to commit the configuration with:

There is more information at:

     http://rackerhacker.com/2008/06/16/adjusting-cpan-mirror-list/

Here are a list of modules that need to be installed:

     install Bundle::CPAN
     force install Date::Calc  (later versions have it already)
     install Time::HiRes

If the install of Time::HiRes fails, exit CPAN, do the following and then rerun the install of HiRes from scratch:

     export LC_ALL=C

Before installing the Informix bundle, you will need to exit CPAN and do the following:

     PATH=/usr/share/informix/bin:$PATH
     INFORMIXDIR=/usr/share/informix
     INFORMIXSERVER=deltoids  (or whatever your Informix server is named)
     export PATH INFORMIXDIR INFORMIXSERVER

Set the environment variables needed by the Perl install script.

     DBPATH=/home/tst/perltest  (pick the user who will own the test directory)
     DBD_INFORMIX_DATABASE=stores
     DBD_INFORMIX_USERNAME=root
     DBD_INFORMIX_PASSWORD=itsasecret  (use the actual root password)
     export DBPATH DBD_INFORMIX_DATABASE DBD_INFORMIX_USERNAME \
         DBD_INFORMIX_PASSWORD

Note that the super user password is now stored in an environment variable in plain text. This is a big security hole. Only do this for the time needed to run the Perl install script.

Make a test directory where the database used by the install script can be stored.

     su
     mkdir /home/tst/perltest
     chown tst:tst /home/tst/perltest
     chmod ug=rwx,o=rx /home/tst/perltest

Change to the newly created test directory. Despite the fact that the DBPATH environment variable is set to the test directory, Informix is such a brain dead piece of scrap that it still creates the new database in the current directory. So, do:

     cd /home/tst/perltest

Create a database in this directory that can be used by the install script. To do so, run "isql" and use the "DATABASE" menu item followed by the "CREATE" menu item. Enter the name of the new database (e.g. "stores") and press enter to create it. Back out of the database menu and switch to the Query Language menu where you should enter and execute the SQL statement:

     grant dba to public

When done, exit from "isql", restart CPAN and then install DBD:

     perl -MCPAN -e shell
     install Bundle::DBD::Informix

We're now done with the Perl test database so we can get rid of it:

     cd /root
     rm -rf /home/tst/perltest

At this point, you must log off to clear the environment variables with the super user password in them. Then, you need to edit root's bash history to delete the line where you set the password. To do that, log on as root again. With your favorite editor, edit /root/.bash_history and remove any lines that contain the root password. Save the file. Log out again (the command that sets the password is still in the in-memory command history). You can log in for a third time and check that the plaintext password is no longer visible in the command history. What a pain in the butt! Nice install procedure.