Calling another Script from Command Line in UNIX


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Calling another Script from Command Line in UNIX
# 1  
Old 06-16-2014
RedHat Calling another Script from Command Line in UNIX

Hi all,

I am having problem in understanding the following line of code ..
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"

Please elaborate Smilie



Moderator's Comments:
Mod Comment Please use code tags next time for your code and data not Bold char! Thanks

Last edited by vbe; 06-17-2014 at 10:43 AM.. Reason: code tags
# 2  
Old 06-16-2014
Welcome to UNIX.COM

.seq

File extensions DO NOT have meaning necessarily to a UNIX OS. This is a Windows thing primarily. Some windows-like Linux desktops can be set up to associate certain applications with a file extension. .mp3, for example, may be associated with whatever media application you have.

Programmers often attach meaningful extensions so that someone seeing the file knows what is in it: foo.dat script.sh script1.ksh. Those extensions do not make or break the function of the file like they do in Windows. In Windows if you rename a file like foo.xlsx - an Excel file - to foo.junk then the Windows OS will not open the file using Excel automatically. You get warning messages when you rename files on Windows because of this very issue. Not on UNIX.

-q

Is a command line parameter, an option. You have to read the script to understand what effect -q has on the logic of the shell script. Nobody here can tell you what it does, anything we said would be a pure guess - if we got it right it would be an accident.
This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 06-16-2014
Thanks very much... This is the code

Code:
#!/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


Last edited by vgersh99; 06-16-2014 at 09:02 AM.. Reason: code tags, please!
# 4  
Old 06-17-2014
What do you see/think you do with it?

The parameters given in the command line are available to the script as $1, $2, $3 etc. relative to their position. I could make a wild guess, but you need to follow where they are used or passed on to decide that.

Often -q would be set as a flag for a Query, to make the script not log/display anything (quiet) or to signal a quit at a certain point, but it has no official meaning, so it depends what you have done with it beyond this script, which seems to be your standard schedule runner.

Follow through where it's used (more than one place) and let us know where you are getting stuck.



Robin


Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Converting xls file to xlsx on UNIX script / command line.

Hi All, Am needing advise on how to convert xls file to xlsx format on Solaris unix command line or scripting. I tried searching online but it looks like I need to either use Perl packages of Excel or Python packages or some other 3rd party tool. Problem is to install any of these will require... (2 Replies)
Discussion started by: arvindshukla81
2 Replies

2. UNIX for Dummies Questions & Answers

Help with reading and calling a command in a script

The problem I am having now is calling and reading a command and The Main script reads the data file and passes the input to the two calculation scripts, and than output to a file. 1. The Main Script ----------------- input=inputfilepj3 output=outfilepj3 echo "*** Converting... (2 Replies)
Discussion started by: TheUnitedOSI
2 Replies

3. UNIX for Dummies Questions & Answers

Calling Macros in UNIX command

Hi .. I have created a sql macro, i want to execute this through ksh in putty.ie) sql.ksh will contain the macro query ,once i call this ksh ,the macro should trigger. I am able to write a macro : for ex: create macro macro_name (sel * from db_tablename) execute macro_name. Could... (1 Reply)
Discussion started by: Kalaiselvi66
1 Replies

4. Programming

Calling UNIX command fron FORTRAN

I want to run the unix command in a fortran code echo trim(val_fgsize) | awk '{split($1, a, "/"); print a}'I am trying like this but getting problems s='echo ' // trim(val_fgsize) // '| awk '{split($1, a, "/"); print a}'' call system(s) ---------- Post updated at 05:15 PM ----------... (1 Reply)
Discussion started by: kristinu
1 Replies

5. Shell Programming and Scripting

UNIX script / Command >>> in one line

Hi Experts, Basically I am a SAP programmer. I don't know much about UNIX. But I got a situation, need to use UNIX script /command in my programming. I searched the forum and found the below code. I would like to pass the below UNIX script in my programming code. But my programming will... (1 Reply)
Discussion started by: rbadveli
1 Replies

6. Shell Programming and Scripting

Running a unix script(which is calling another script inside that) in background

Hi all, I am having a script ScriptA which is calling a script ScriptB in the same server and copying files to second server and have to execute one script ScriptC in the second server. THis First script ScriptA is the main script and i have to execute this process continously. for Keeping... (2 Replies)
Discussion started by: rohithji
2 Replies

7. Shell Programming and Scripting

calling sub-script in a command while

Hi, I am writting a script reading a liste of files from a file-list using the command while read NEW_LINE, and calling a "ksh" shell for each line. My shell is like beside, and only the first line of the file-list of "/app/admin/file-list.txt" is actually processed. It seems that calling a... (2 Replies)
Discussion started by: astjen
2 Replies

8. Shell Programming and Scripting

calling unix script from JSP???

Hi all, i have requirement where i need to call a unix script from a JSP code. my script should list all the csv files from a directory and then should upload the file names to an oracle table (using sqlloader). i tried using getRuntime function in JAVA to call my script and was successfully... (1 Reply)
Discussion started by: Bhups
1 Replies

9. Programming

calling UNIX script from C/C++

Hi all, Is it possible to call a UNIX script from C/C++ program? If yes, can you please tell me how? Thank you in advance Regards (3 Replies)
Discussion started by: omran
3 Replies

10. UNIX for Dummies Questions & Answers

Java program calling a UNIX command

I was wondering if it was possible to call a unix command directly from a Java program during run-time. This command could very very basic e.g. "ps -ef" returned as a string, all I need is a starting place so if anyone has any suggestion or examples I would be very grateful (2 Replies)
Discussion started by: QUartz Ite
2 Replies
Login or Register to Ask a Question