Topic
  • 8 replies
  • Latest Post - ‏2019-05-28T06:50:22Z by RT123
RT123
RT123
28 Posts

Pinned topic Execute map from Shell script

‏2019-05-13T07:23:30Z |

Hi,

 

I need to call a ITX map form within a shell script. The map should do the following:

 

  • The script should run an  ITX map (mmc file)
  • The map started should continue to use ITX configuration file (config.mrn). The variable put on the map will be replaced by the file from the configuration file.
  • The script should return the value "1" if it's failed or just echo when it's OK. 

Any help would be greatly appreciated.

 

 

Updated on 2019-05-14T13:30:23Z at 2019-05-14T13:30:23Z by PaulBrett
  • PaulBrett
    PaulBrett
    356 Posts
    ACCEPTED ANSWER

    Re: Execute map from Shell sript

    ‏2019-05-14T05:44:08Z  

    Did you open and view the file?  In dtx.ini you will find:

    ; this defines what resource configuration file to use for the Command Server:                                    
    ;ResourceCfgFile=resource.mrc

    and

    ; this defines what resource configuration file to use for the Launcher:
    ;ResourceCfgFile=resource.mrc

    I recommend you set the location of your MRC file in both these places (and remove the semi colon to un-comment the lines).  Example:

    ; this defines what resource configuration file to use for the Command Server:                                    
    ResourceCfgFile=/opt/IBM/itx900/config/resource.mrc

    Thank you.

    Paul

    Follow me on Twitter

    Updated on 2019-05-14T05:45:11Z at 2019-05-14T05:45:11Z by PaulBrett
  • PaulBrett
    PaulBrett
    356 Posts

    Re: Execute map from Shell sript

    ‏2019-05-13T13:01:05Z  

    You need to use the Command Server (dtxcmdsv).  The Resource Registry file MRC will be picked up if you have referenced it in both place in the dtx.ini file.  The MRC file will use the MRN file referenced in the Command Server section.

    Usual errorlevel checking can be used, as per any other type of script.

    Thank you.

    Paul

    Follow me on Twitter

  • RT123
    RT123
    28 Posts

    Re: Execute map from Shell sript

    ‏2019-05-14T05:02:27Z  
    • PaulBrett
    • ‏2019-05-13T13:01:05Z

    You need to use the Command Server (dtxcmdsv).  The Resource Registry file MRC will be picked up if you have referenced it in both place in the dtx.ini file.  The MRC file will use the MRN file referenced in the Command Server section.

    Usual errorlevel checking can be used, as per any other type of script.

    Thank you.

    Paul

    Follow me on Twitter

    Thank You Response Paul. 

     

    Can you please elaborate on what it means by referencing the MRC file in both the place in dtx.ini file. 

    I have used the dtxcmdsv command server command: My script is pasted below:

    The below script fails to pickup values from the config.mrn file. Please suggest.

     

    #!/bin/ksh
    ## --------------------------------------------------------------------------- #
    ##                                                   #
    ## --------------------------------------------------------------------------- #

    . /$MACHINE/apps/common/librairies_communes.ksh
    . /$MACHINE/apps/common/jobInitialize.ksh ${0} "$*"

    # --------------------------------------------------------------------------- #
    # VARIABLES
    # --------------------------------------------------------------------------- #

    #export PARM="/abcdefgh/apps/xyz/config/"
    #export _GEDPARM="/abcdefgh/apps/xyz/config/config.mrn"
    FLOG=${SYSOUT}
    #PARAM=${PARM}

    # --------------------------------------------------------------------------- #
                                                     #
    # --------------------------------------------------------------------------- #
    f_GenDateFromDB()
    {         
                    
            echo "*-------------------------------------------------------*"
            echo "* Launch the map           *"
            echo "*-------------------------------------------------------*"
            echo $_GEDPARM
            #echo $PARAM
                    ${DTX_HOME_DIR}/bin/dtxcmdsv /abcdefgh/apps/xyz/map/DATE_MAP.mmc         
            CODE_RET=$?
            
            if [ $CODE_RET -ne 0 ]
            then
                    echo "Failed to execute DATE_MAP.mmc  - KO" > ${FLOG}
                    exit 1
            else
                    echo "Successful executution of DATE_MAP.mmc OK" > ${FLOG}
            fi
    }a

    # --------------------------------------------------------------------------- #
    # MAIN
    # --------------------------------------------------------------------------- #

    jobDebut
    f_GenDateFromDB 
    jobFin

  • PaulBrett
    PaulBrett
    356 Posts

    Re: Execute map from Shell sript

    ‏2019-05-14T05:44:08Z  

    Did you open and view the file?  In dtx.ini you will find:

    ; this defines what resource configuration file to use for the Command Server:                                    
    ;ResourceCfgFile=resource.mrc

    and

    ; this defines what resource configuration file to use for the Launcher:
    ;ResourceCfgFile=resource.mrc

    I recommend you set the location of your MRC file in both these places (and remove the semi colon to un-comment the lines).  Example:

    ; this defines what resource configuration file to use for the Command Server:                                    
    ResourceCfgFile=/opt/IBM/itx900/config/resource.mrc

    Thank you.

    Paul

    Follow me on Twitter

    Updated on 2019-05-14T05:45:11Z at 2019-05-14T05:45:11Z by PaulBrett
  • RT123
    RT123
    28 Posts

    Re: Execute map from Shell sript

    ‏2019-05-14T08:44:19Z  
    • PaulBrett
    • ‏2019-05-14T05:44:08Z

    Did you open and view the file?  In dtx.ini you will find:

    ; this defines what resource configuration file to use for the Command Server:                                    
    ;ResourceCfgFile=resource.mrc

    and

    ; this defines what resource configuration file to use for the Launcher:
    ;ResourceCfgFile=resource.mrc

    I recommend you set the location of your MRC file in both these places (and remove the semi colon to un-comment the lines).  Example:

    ; this defines what resource configuration file to use for the Command Server:                                    
    ResourceCfgFile=/opt/IBM/itx900/config/resource.mrc

    Thank you.

    Paul

    Follow me on Twitter

    Thank you so much Paul. It works perfectly. :)

  • RT123
    RT123
    28 Posts

    Re: Execute map from Shell script

    ‏2019-05-24T09:15:03Z  

    Hi Paul,

     

    The shell script pasted above works, but it doest return the correct error code when it fails. I am trying to call a series of maps using shell. My Shell script will call the first map which will consequently call the second map. 

     

    Now if my second map fails i get the error on screen "Exit call failed". I want to fail the map, but the return code is 0 and hence the map completes successfully. Can you let me know how i can modify the below script to fail base don error code. 

     

    Thanks

     

    #!/bin/ksh
    ## --------------------------------------------------------------------------- #
    ##                                                   #
    ## --------------------------------------------------------------------------- #

    . /$MACHINE/apps/common/librairies_communes.ksh
    . /$MACHINE/apps/common/jobInitialize.ksh ${0} "$*"

    # --------------------------------------------------------------------------- #
    # VARIABLES
    # --------------------------------------------------------------------------- #

    #export PARM="/abcdefgh/apps/xyz/config/"
    #export _GEDPARM="/abcdefgh/apps/xyz/config/config.mrn"
    FLOG=${SYSOUT}
    #PARAM=${PARM}

    # --------------------------------------------------------------------------- #
                                                     #
    # --------------------------------------------------------------------------- #
    f_GenDateFromDB()
    {         
                    
            echo "*-------------------------------------------------------*"
            echo "* Launch the map           *"
            echo "*-------------------------------------------------------*"
            echo $_GEDPARM
            #echo $PARAM
                    ${DTX_HOME_DIR}/bin/dtxcmdsv /abcdefgh/apps/xyz/map/DATE_MAP.mmc         
            CODE_RET=$?
            
            if [ $CODE_RET -ne 0 ]
            then
                    echo "Failed to execute DATE_MAP.mmc  - KO" > ${FLOG}
                    exit 1
            else
                    echo "Successful executution of DATE_MAP.mmc OK" > ${FLOG}
            fi
    }a

    # --------------------------------------------------------------------------- #
    # MAIN
    # --------------------------------------------------------------------------- #

    jobDebut
    f_GenDateFromDB 
    jobFin

  • PaulBrett
    PaulBrett
    356 Posts

    Re: Execute map from Shell script

    ‏2019-05-24T10:54:21Z  

    You would need to force the first map to fail, by wrapping the call to the RUN() function in a VALI()/FAIL() pair.  Example

    =RUN("ChildMap.mmc",ECHOIN(1,Input1)+" -OE5")

    would change to 

    =VALID(RUN("ChildMap.mmc",ECHOIN(1,Input1)+" -OE5"),FAIL("Child map failed to run : "+LASTERRORMSG()))

    Only then would your script be able to detect that the call to the Command Server failed.

    Thank you.

    Paul

    Follow me on Twitter

  • RT123
    RT123
    28 Posts

    Re: Execute map from Shell script

    ‏2019-05-27T08:14:24Z  

    Thank you Paul.

    Can you explain what OE5 includes here in the RUN command. What Input1 carries?

     

  • RT123
    RT123
    28 Posts

    Re: Execute map from Shell script

    ‏2019-05-28T06:50:22Z  
    • RT123
    • ‏2019-05-27T08:14:24Z

    Thank you Paul.

    Can you explain what OE5 includes here in the RUN command. What Input1 carries?

     

    Hi Paul,

     

    I executed the above script and it always fails with error code 30. The error message being "Fail function aborted the map". The user defined error "Child map failed to run" isn't thrown back. Please suggest.

     

    Thanks