Using an Informix Database

If you'd like to set up the databases for a particular system in a separate user's home directory, you should add those users now. For example:

     /usr/sbin/useradd -c "Collection System" -m coll

If you want to give the new userid a password:

     passwd coll

To run Informix from a user's home directory, you must set up several environment variables. The following shell script or something like it but altered as appropriate for the system in question, might be useful.

setupinfx:

     #!/bin/sh
     #
     # Set up the development environment for Collect under Informix on Linux.
     #
     # Be sure to run this script with the "." command.  For example:
     #
     #   . /home/coll/devenv
     #
     # If you do not use the "." command, the values of the environment
     # variables will not be set in the current shell environment.
     #
     INFORMIXDIR=/usr/share/informix
     INFORMIXSERVER=deltoids
     DBPATH=/home/coll/colldev
     DBTEMP=/home/coll/dbtmp
     MAKE_INSTALL=/home/coll/colldev
     export INFORMIXDIR INFORMIXSERVER DBPATH DBTEMP MAKE_INSTALL
     #
     # Set up the locale, if need be.
     #
     #CLIENT_LOCALE=en_us
     #DB_LOCALE=en_us
     #SERVER_LOCALE=en_us
     #export CLIENT_LOCALE DB_LOCALE SERVER_LOCALE
     #
     # Note that the gang at RedHat has screwed up the threads library
     # implementation on RedHat 9 such that the Informix tools get segmentation
     # violations.
     #
     # The segmentation violation or segmentation fault problems are due to
     # RedHat 9.0 including the Native POSIX Thread Library (NPTL), a new
     # implementation of POSIX threads for Linux.
     #
     # This library provides performance improvements and increased scalability
     # for i686 or better processors.  This thread library is designed to be
     # binary compatible with the old Linux Threads implementation; however,
     # applications that rely on the places where the Linux Threads implementation
     # deviates from the POSIX standard will need to be fixed.
     #
     # If an application does not work properly with NPTL, you can run it using
     # the old Linux Threads implementation by setting the following environment
     # variable:
     #
     #     LD_ASSUME_KERNEL=kernel-version
     #
     # The following versions are available:
     #
     #     2.4.1 - Linuxthreads with floating stacks
     #     2.2.5 - Linuxthreads without floating stacks
     #
     # To find out what the current kernel version of Red Hat is, we issue this
     # command:
     #
     #     uname -r
     #
     # If the kernel version is something like "2.4.18-26.8.0" or "2.4.20-8", we
     # use "2.4.1".  Otherwise, if it is a version 2.2 kernel, we use "2.2.5".
     # For later versions of the kernel, such as "2.6.18-92.1.18.el5", nothing
     # need be done.
     #
     KernelVer=`uname -r`
     echo $KernelVer | grep -q "^2.2"
     DirVal=$?
     if [ $DirVal == 0 ]; then
         echo Assuming kernel version 2.2.5
         LD_ASSUME_KERNEL=2.2.5; export LD_ASSUME_KERNEL
     else
         echo $KernelVer | grep -q "^2.4"
         DirVal=$?
         if [ $DirVal == 0 ]; then
             echo Assuming kernel version 2.4.1
             LD_ASSUME_KERNEL=2.4.1;
             export LD_ASSUME_KERNEL
         fi
     fi
     #
     # The fabulous Informix install scripts don't put links to the dynamic
     # libraries into the /usr/lib directory.  If you'll be building 4GL programs
     # or trying to run certain Informix utilities, you may install the links
     # yourself to get them to work.  The following command will list the files
     # needing links:
     #
     #     find /usr/share/informix -name \.so -print
     #
     # If you are happy with what you see (i.e. it makes sense that the libraries
     # listed should be included in the dynamic libraries load path), the
     # following command will actually make the links in /usr/lib:
     #
     #     find /usr/share/informix -name \.so -exec ln -s \{\} /usr/lib \;
     #
     # On modern Linux systems including the latest CentOS/RedHat and Ubuntu,
     # the preferred method for fixing this problem is to add a file to
     # /etc/ld.so.conf.d that contains a list of all of the dynamic library
     # directories.  You can determine all of the directories that contain
     # dynamic libraries in the Informix install path with the same command as
     # shown above:
     #
     #   find /usr/share/informix -name \*.so -print
     #
     # If you do this on your system, you'll probably came up with a file,
     # call it /etc/ld.so.conf.d/informix-i386.conf, that looks like this:
     #
     #   /usr/share/informix/lib/c++
     #   /usr/share/informix/lib/cli
     #   /usr/share/informix/lib/client/csm
     #   /usr/share/informix/lib/dmi
     #   /usr/share/informix/lib/esql
     #   /usr/share/informix/lib/icc/icclib
     #   /usr/share/informix/lib
     #
     # If neither of these approaches are taken, a final alternative approach
     # is to add the informix libraries to the loader's dynamic library search
     # path, which is what we do on the fly, here.  It will work in conjunction
     # with either the symlink approach or the ld.so.conf approach, mentioned
     # above so there is no harm in doing it here, just in case.  Kind of like
     # wearing a belt and suspenders too.
     #
     # Note that we only do this if the Informix libraries are not already on the
     # search path.
     #
     echo $LD_LIBRARY_PATH | grep -q "$INFORMIXDIR/lib"
     DirVal=$?
     if [ $DirVal != 0 ]; then
         LD_LIBRARY_PATH=$INFORMIXDIR/lib:$INFORMIXDIR/lib/esql:\
             $INFORMIXDIR/lib/tools:$LD_LIBRARY_PATH
         export LD_LIBRARY_PATH
     fi
     #
     # Set the path to include the Informix binary directory at the front, if
     # it isn't already there.
     #
     echo $PATH | grep -q "$INFORMIXDIR/bin"
     DirVal=$?
     if [ $DirVal != 0 ]; then
         PATH=$INFORMIXDIR/bin:$PATH
     fi
     #
     # Now, add the current directory.
     #
     echo $PATH | grep -q "\.:"
     DirVal=$?
     if [ $DirVal != 0 ]; then
         PATH=.:$PATH
     fi
     export PATH
     #
     # Tell the database to use the termlp program for printing.  This program
     # will redirect output to the terminal in such a way as to cause the
     # emulator to print it on the user's local printer.
     #
     # Basically, this program sends:
     #
     #   <esc>[5i
     #   <esc>E
     #   <esc>(s12H
     #
     # Followed by the file to be printed.
     #
     # Followed by:
     #
     #   <esc>[4i
     #
     # This switches on the printer port on the local PC, resets the printer,
     # sets it to 12 cpi (96 colums in portrait, 136 columns in landscape),
     # prints the file, then turns the printer port off.
     #
     DBPRINT=/home/coll/colldev/termlp
     export DBPRINT
     #
     # The regular termcap doesn't work with Informix 4GL programs.  You can
     # use the one that Informix supplies but we have our own.
     #
     # Incidentally, later versions of Linux use terminfo, not termcap, but
     # Informix didn't get that memo, hence the need for its own termcap.
     #
     #TERMCAP=${INFORMIXDIR}/etc/termcap; export TERMCAP
     TERMCAP=/home/coll/termcap.OLDRH; export TERMCAP
     #INFORMIXTERM=terminfo; export INFORMIXTERM
     #
     # Display the Informix directory choices for the user.
     #
     echo Informix directory: $INFORMIXDIR
     echo Informix server and path: $INFORMIXSERVER, $DBPATH
     #
     # Change to the build directory (this is important, since Informix can
     # screw over the wrong database tables, if you don't do this).  Note that
     # the ACTIVE_COLL_DIR is just a variable that we set for our convenience.
     # It has nothing to do with Informix.
     #
     ACTIVE_COLL_DIR=/home/coll/colldev; export ACTIVE_COLL_DIR
     cd /home/coll/colldev

After you've set up this script, you can invoke it from the user's login script or you can run it from the command line like this:

     . ./setupinfx

This should now allow you to run Informix, Informix tools and any 4GL programs with impunity. However, if you experience an error that looks like this:

     Program stopped at "xxx.4gl", line number 0.
     SQL statement error number -404.
     The cursor or statement is not available.

It is probably because the Informix database engine isn't running, or because you've set the wrong values for INFORMIXSERVER or DBPATH. This is basically Informix' way of telling you that it can't find your database. Its just not real strong on being transparent. Better you should have to work a bit to figure out what's going on.