Missing flag for HP UX Korn shell.


A post after a long time…

Been working on a project which requires the end product to be able to work in multiple OS platforms ( Solaris, HP UX and Linux ).

This project has a shells script which executes certain statements depending on whether a particular file exists or not. Typically, I would accomplish that using the –e flag. However, turns out that HP UX korn shell doesn’t really have this option. So our scripts used to fail all and sundry on any HP UX box. Turns out we need to use the –f flag in HP UX.

so in Linux it would be

if [ –e $CONTROLFILE ]

then

……

 

in HP
if [ –f $CONTROLFILE ]

then

……

 

but yeah, –f works in Linux too… So, lesson here, use the least common denominator.

Data Store connection timeout in ExtJS


I have recently started working with the ExtJS javascript library. Its one of the coolest libraries that I have used so far. Initially it does look a bit intimidating, but then as you go through the samples and the different examples, you would get comfortable. And of course the forums are quite helpful.

Coming back to what this post is about.

For my project, we needed to display a grid report as per one of the business requirements. This report is based on a SQL query which takes sometime to run and it takes sometime to create a JSON object out of the result set. To be precise, it took 84 seconds for the data to be sent from the server.

What used to happen was that, for the first 30 seconds a display mask would be visible over the grid. But then at the end of the 30 seconds the display mask would disappear and the grid would be empty. The grid contained a data store which was fetching these records from the server

Even though, the data was being prepared at the server, it was not able to send the data to the client, since the connection used to timeout after 30 seconds.

After searching on Google, I came across a few suggestions, which asked me to include pagination in the grid. But then this was not acceptable to business. They wanted the whole report in one go.

After some more googling, I found that there is a connection object which can be defined for the data store. In this connection object, we can define the timeout limit. Once we define this connection object we can use this in our data store. And this solved my problem… at least for now. Following is the code snippet.

 

var connObj = new Ext.data.Connection({
            timeout : 120000,
            url : ‘/jsp/dataSourceURL’,
            method : ‘POST’
        });

var dataStore = new Ext.data.Store({
            // load using HTTP
            proxy : new Ext.data.HttpProxy(connObj),
            reader : new Ext.data.JsonReader({
                        root : ‘rows’,
                        totalProperty : ‘results’
                    }, recordFormat)
        });

Hope this helps anyone stuck in a similar scenario.

Though, if budget permits, you can check a user extension called live grid. This seems good.

http://www.siteartwork.de/livegrid_demo/

Oracle 10g Installation on Fedora 9.


Yup, this is a release old for installation notes for Oracle 10g. But, I couldn’t get Fedora 10g installed. Some issues with the display. So had to rollback (reinstall) Fedora 9. And start with Oracle 10g installation on it. So here we go…

This is an adaptation of the installation steps as provided in the following website.

http://www.oracle-base.com/articles/10g/OracleDB10gR2InstallationOnFedora7.php

Thanks to Tim for his wonderful website!! 🙂

The steps that I mention below, are what I have done on my desktop. And this is for local database host for my self development purposes. I hope it helps others who are interested.

1. Please check the /etc/hosts file to check if you have an entry for a fully qualified host name.

I have the following entry:

[root@localhost wolverine]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost.localdomain localhost localhost
::1             localhost6.localdomain6 localhost6
192.168.1.111   cerebro cerebro

2. Add the following entries to /etc/sysctl.conf file.

    kernel.shmall = 2097152
    kernel.shmmax = 2147483648
    kernel.shmmni = 4096
    # semaphores: semmsl, semmns, semopm, semmni
    kernel.sem = 250 32000 100 128
    fs.file-max = 65536
    net.ipv4.ip_local_port_range = 1024 65000
    net.core.rmem_default=262144
    net.core.rmem_max=262144
    net.core.wmem_default=262144
    net.core.wmem_max=262144

Run the command /sbin/sysctl –p to change the parameters at runtime.

3. Add the following entries to /etc/security/limits.conf file.

       *               soft    nproc   2047
       *               hard    nproc   16384
       *               soft    nofile  1024
       *               hard    nofile  65536

4. Modify the file /etc/pam.d/login by adding following line if it doesn’t exist.

session    required     /lib/security/pam_limits.so

5. Disable secure linux by setting the SELINUX flag

      SELINUX=disabled

6. Install the following.

     yum install libXp libaio
     yum install compat-libstdc++* compat-libf2c* compat-gcc* compat-libgcc*
     yum install tcl*
     yum install compat-db*
     yum install libXau-devel-*

  7.  Now comes the part for adding the users for Oracle Installation.

      groupadd oinstall
      groupadd dba
      groupadd oper

      useradd -g oinstall -G dba oracle
      passwd oracle

   8.  Create directories required for Oracle, and assign the required privileges.

      mkdir -p /u01/app/oracle/product/10.2.0/db_1
      chown -R oracle.oinstall /u01

   9.  Set up the .bash_profile with following entries.

     # Oracle Settings
     TMP=/tmp; export TMP
     TMPDIR=$TMP; export TMPDIR

     ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
     ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1; export ORACLE_HOME
     ORACLE_SID=TSH1; export ORACLE_SID
     ORACLE_TERM=xterm; export ORACLE_TERM
     PATH=/usr/sbin:$PATH; export PATH
     PATH=$ORACLE_HOME/bin:$PATH; export PATH

     LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
     CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

     if [ $USER = "oracle" ]; then
       if [ $SHELL = "/bin/ksh" ]; then
         ulimit -p 16384
         ulimit -n 65536
     else
         ulimit -u 16384 -n 65536
       fi
     fi

10.  Unzip the database archive and cd to the database directory.

11. run the installer with the following option.

     runinstaller –ignoreSysPrereqs

     This will skip the check for the OS.

12. This will show the following screen.

     image

13.  Click on next, which shows the following screen.

     image

 

14.  Select the required Database installation option.

    image   

15. Specify the home details.

    image 

16. This will bring us to the next screen.

    image    

    For my installation, since I have chosen to not update the redhat-release file, I get the warnings

    These can be overridden using the check boxes.

17.  Select the database configuration options.

      image

 

18.  Select the General Purpose option and click on proceed.

19.  This shows the next screen, clink on install to start the database installation.

20. Once the installation is completed (it went through successfully for me.) you will get another screen which helps configure the database.

image

21.  I would be using Custom Database option.

       Enter the required name as the SID.

image

22. The next screen gives option to select the backup and the database configuration options.

   Select the option for Enabling EM for Database configuration.

image

23. Click on next. This shows the screen as below:

  Define the required passwords:

image

24. As I mentioned that this is a dev database hosted on a desktop, I am using the file system option for the Database Storage.

image

25. Select the required option.

image

26. Click on next.

image

27. Click on next.

Define the memory options as required.

image

28. Click on next. This shows the installation parameters.

image

29. You can user the next screen to save the database configuration as a template if you wish to retain it.

image

30. Click finish.

This starts the process for Oracle instance creation and startup.

31. Once Instance creation is completed, the installer would prompt you for password management options.

32. The installer will then prompt you to run two scripts as the root user. Open another session and login as root and run the scripts as indicated in the popup.

33. Click on ok.

34. The Oracle installation is complete. The installer would provide you with information about the urls where you can use 10g EM and iSQLPlus.

Now you can try connecting through sqlplus and check if the installation is done correctly.

All the best!!

Nif – tee


This is another entry to my blog after a long hiatus. And I think, I can rev up my blog engine with a very small entry on a nifty unix tool named ‘tee’.

So what does tee do? It creates two output streams for the inputs it receives.

When the output from any command is piped into tee, it displays the output on the STDOUT, and also send the output into the argument to tee.

so something like below would display the output and also write it into the file passed as an argument to tee.

date | tee date_log.log

This would display the date on the STDOUT and also write it into date_log.log

Nifty isn’t it?

What a find…


One of the most powerful commands in Unix is the find command. Its amazing to see what all can be accomplished with this command. A question that was once asked to me was how to find all the files which contain a particular word in it.

For the sake of this example lets say the word in question was “xyz”

The person who asked was convinced that ls -ltr | grep -i “xyz” would work fine. NO. It does’nt. The reason is that, ls -ltr would give a text output, which would then be piped to the grep command. So what would essentially happen is that the grep command would act on the names of the files being listed, rather than the contents of the files.

Ex: if the directory where you run ls -ltr contains three files, file1.txt, file2.txt, file3.txt the following output would be displayed.

-rw-r--r-- 1 oracle oinstall 0 Aug 24 18:24 file1.txt
-rw-r--r-- 1 oracle oinstall 0 Aug 24 18:24 file2.txt
-rw-r--r-- 1 oracle oinstall 0 Aug 24 18:25 file3.txt

And grep would act on this output. It would be the same as using grep on a file containing this data.

So how do we do this?

The find command comes in handy in such a scenario. The command which does the trick is below. I am assuming that the command is being run in the directory where the files are located. Alernatively, the entire path can also be provided.

find . -name “*.*” -exec grep -i “xyz” { } \;

Note: There is a space in between the braces here. This is just for display purposes. Please remove it when typing the command.

The key part in the command giving the required results is the exec command which executes the commands grep -i “xyz” on every filename thats provided by the find command. The braces { } \; represent the filename from the find command.

This is just one of the options in the find command. There are plenty of others using which a variety of tasks can be accomplished using the most simplest methods.