Informix

 View Only
  • 1.  onstat -c $INFORMIXDIR result

    Posted Tue November 22, 2022 12:42 PM
    Hi,

    I have one script that uses onstat results as arguments, on bash I am veryfing one issue.
    As INFORMIXDIR appears on some variables they are not resolved by shell
    #!/bin/bash
    ONLINELOG=$(onstat -c | grep "^MSGPATH")
    # This command return something like $INFORMIXDIR/tmp/online.log
    grep "Something" "$ONLINELOG"
    

    returns

    grep: MSGPATH $INFORMIXDIR/tmp/online.log: No such file or directory

    The variables are defined and loaded into the environment, however $INFORMIXDIR appears as a string
    I am using CentOS 8.6 and bash 4.4.20

    Thanks for any help

    SP



    ------------------------------
    Sergio Peres
    AIRC
    Coimbra
    ------------------------------

    #Informix


  • 2.  RE: onstat -c $INFORMIXDIR result

    IBM Champion
    Posted Tue November 22, 2022 12:49 PM
    You will need to expand INFORMIXDIR to it's value in the script.  Take a look at the eval command.

    Another things is to use onstat -g cfg MSGPATH and grep the value from that output...that usually has expanded the full path already.

    ------------------------------
    Mike Walker
    xDB Systems, Inc
    www.xdbsystems.com
    ------------------------------



  • 3.  RE: onstat -c $INFORMIXDIR result

    Posted Wed November 23, 2022 10:50 AM
    Thanks for reply,

    It work like a charm :)

    Best regards

    ------------------------------
    Sergio Peres
    AIRC
    Coimbra
    ------------------------------



  • 4.  RE: onstat -c $INFORMIXDIR result

    IBM Champion
    Posted Tue November 22, 2022 12:57 PM
    Sergio:

    It's not complaining about INFORMIXDIR, it is complaining about the arguements to bash on the ## line.

    Is this what you are trying to accomplish:

    art@Elezar-II:~$ cat aa
    #!/usr/bin/bash  
    export ONLINELOG=$(onstat -c | grep "^MSGPATH" | cut -d\  -f2)
    # This script sets an environment variable for the rest of the session from  
    # ONCONFIG output from onstat
    echo "ONLINELOG=$ONLINELOG"

    art@Elezar-II:~$ ./aa
    ONLINELOG=$INFORMIXDIR/tmp/online.log




    ------------------------------
    Art S. Kagel, President and Principal Consultant
    ASK Database Management Corp.
    www.askdbmgt.com
    ------------------------------



  • 5.  RE: onstat -c $INFORMIXDIR result

    Posted Wed November 23, 2022 10:53 AM
    Thanks for reply Art,

    My problem is that shell do not replace variable for the correct value an dreturns error.

    Using Mike solution works fine and give teh correct value, I have tested over version 12 and 14 and works on both.

    Best regards,

    SP

    ------------------------------
    Sergio Peres
    AIRC
    Coimbra
    ------------------------------