在UNIX中从命令行调用另一个脚本

时间:2022-03-20 01:48:06

I am having problem in understanding the following line of code ..

我在理解以下代码行时遇到问题。

/home/rmsbatch/autoscript/autorms.ksh dc_load_main.ksh -q belk_dc_load_tran_data.seq

What's being done here ? what does "-q" means ? What does ".seq" file means in unix "belk_dc_load_tran_data.seq"

这里做了什么? “-q”是什么意思? “.seq”文件在unix“belk_dc_load_tran_data.seq”中的含义是什么

Please elaborate

请详细说明

autorms.ksh

autorms.ksh


#!/bin/ksh
################################################################################
# Description : Execute RMS Jobs with Error Reporting
# 
################################################################################
. /home/rmsbatch/.profile
set -x
LOG=/logs/IBM/AutoLogs
CMNLOG=$LOG/BatchStatus_`date +"%y%m%d`.txt

if [ "${1}" == "prepost" ] || [ "${1}" == "bprepost" ]
then
        exec > ${LOG}/Auto_${1}_${3}.log 2>&1
else
        exec > ${LOG}/Auto_${1}.log 2>&1
fi



function Error_Log
{
# translate "\n" to "^" below
v1=$(echo -n $1 | tr "\n" "^")
v2=$(echo -n $2 | tr "\n" "^")
echo $(hostname)"|"$(basename $CMD $PARAM3)"|"$(date +%m/%d/%y)"|"$(date +%H:%M:%S)"|"$v1"|"$v2 |grep "Failed"
if [[ $? -eq 0 ]]
then
echo $(hostname)"|"$(basename $CMD $PARAM3)"|"$(date +%m/%d/%y)"|"$(date +%H:%M:%S)"|"$v1"|"$v2 | mail -s "RMS Batch Failed in PROD" rms_app_support@belk.com,bandrest@in.ibm.com,vanarsda@us.ibm.com,wgwinslo@us.ibm.com
fi
echo $(hostname)"|"$(basename $CMD $PARAM3)"|"$(date +%m/%d/%y)"|"$(date +%H:%M:%S)"|"$v1"|"$v2 >> $CMNLOG

}




function RunBatch
{
set -x
                echo "Running the Batch or Script"
                echo "Command" $CMD
                if [[ $check -ne 1 ]]
                then
                        ls $MMBIN/$CMD

                        if [ $? == 0 ] || [ $uRC -eq 0 ]
                        then
                                 echo "------ Running the Command ------"
                                 Error_Log "$(basename $CMD $PARAM3) Started"
                 if [ "${CMD}" == "prepost" ] || [ "${CMD}" == "bprepost" ]
                 then
                    ${MMBIN}/${CMD} $PARAM1 $PARAM3 $PARAM4 $PARAM5
                    echo $?| read VResult
                 else
                    cd $MMBIN
                    $SHOME/batch_wrapper.ksh ${CMD} $PARAM1 $PARAM3 $PARAM4 $PARAM5
                    echo $?| read VResult
                 fi 
                 if [ $VResult -eq 0 ]
                 then
                    Error_Log "$(basename $CMD $PARAM3) Batch Completed Successfully"
                    VResult=0
                    return $VResult
                 else
                    cat $MMHOME/error/err.${CMD}*.`date +"%b_%d"`|tail -1|grep error    
                    echo $error|read Error
                    echo `$SHOME/batch_wrapper.ksh ${CMD} $PARAM1 $PARAM3 $PARAM4 $PARAM5`|read Error1
                    Error_Log "$(basename $CMD $PARAM3) Failed with - $Error Error1"     
                    return $VResult
                 fi


                        else
                                 echo " Command not found in the Directory "
                                 Error_Log "$(basename $CMD $PARAM3) Failed for Command Not Found"
                                 VResult=99
                 return $VResult
                        fi
                else
                        echo "------ Running the Command ------"
                        Error_Log "$(basename $CMD $PARAM3) Started"
                        $MMHOME/external/scripts/$CMD.ksh $PARAM1 $PARAM3 $PARAM4 $PARAM5 $PARAM6 $PARAM7
                        echo $?|read Result
                        VResult=$Result
                        if [ $VResult -eq 0 ]
            then
                Error_Log "$(basename $CMD $PARAM3)  Batch Completed Successfully"
                return $VResult
            else
                Error_Log "$(basename $CMD $PARAM3) Failed" 
                return $VResult
            fi
                fi

}


if [[ $# -gt 0 ]]
then
        echo $1|grep ksh
        if [[ $? -ne 0 ]]
        then
                CMD=$1
        else
                echo $1|awk -F"." '{print $1}'|read CMD
                check=1
        fi
        LOGIN=$UP
        PARAM1=$2
        PARAM3=$3
        PARAM4=$4
        PARAM5=$5
        PARAM6=$6
        PARAM7=$7

        MMBIN=$MMHOME/oracle/proc/bin
    SHOME=/home/rmsbatch/autoscript
        echo " Shell Started the Command :" ${CMD}
        echo " Parameters Passed are     :" $*
        echo " MM Home Directory         :" $MMHOME


    RunBatch


else
        echo "##############################################################################################################################"
        echo "# Not Enough Parameter Passed Or Usage of Parameter is not Proper"
        echo "# value to be Passed to the Current Shell is : " $#
        echo "# Command being executed is : " $CMD
        echo "# Usage of current command is given below "
        echo ""
        echo "" `$MMHOME/oracle/proc/bin/$1`
        echo "##############################################################################################################################"
        return 99
fi

1 个解决方案

#1


1  

autorms.ksh is probably a shell script that takes 3 parameters...

autorms.ksh可能是一个带有3个参数的shell脚本......

the first of which looks to be another script (dc_load_main.ksh) but it is only a guess and not necessarily the case

第一个看起来是另一个脚本(dc_load_main.ksh)但它只是猜测而不一定是这种情况

the second is -q which could mean anything

第二个是-q,这可能意味着什么

the third is probably another file but you cannot tell what the file should contain as extensions are fairly arbitrary and not enforced in Unix.

第三个可能是另一个文件,但你无法分辨文件应该包含什么,因为扩展是相当随意的,而不是在Unix中强制执行。

In short, you need to read autorms.ksh to know anything at all.

简而言之,您需要阅读autorms.ksh才能知道任何事情。

#1


1  

autorms.ksh is probably a shell script that takes 3 parameters...

autorms.ksh可能是一个带有3个参数的shell脚本......

the first of which looks to be another script (dc_load_main.ksh) but it is only a guess and not necessarily the case

第一个看起来是另一个脚本(dc_load_main.ksh)但它只是猜测而不一定是这种情况

the second is -q which could mean anything

第二个是-q,这可能意味着什么

the third is probably another file but you cannot tell what the file should contain as extensions are fairly arbitrary and not enforced in Unix.

第三个可能是另一个文件,但你无法分辨文件应该包含什么,因为扩展是相当随意的,而不是在Unix中强制执行。

In short, you need to read autorms.ksh to know anything at all.

简而言之,您需要阅读autorms.ksh才能知道任何事情。