Sponsored Content
Top Forums Shell Programming and Scripting Error in script for set command Post 302580269 by vee_789 on Thursday 8th of December 2011 04:07:57 AM
Old 12-08-2011
Error in script for set command

Hi All
I have a function in a Linux script as follows
Code:
echo `date`": Info:         Started Checking File Pattern(s)"
cat ${CM_FILE_SPLIT_LST} | while read SPLIT_INFO
do
        #lets not expand wildcards
        set -f
        #FILE_PATTERN=`echo ${SPLIT_INFO} | awk '{FS="|"; print $1}'`
        FILE_PATTERN=`echo ${SPLIT_INFO} | awk -F"|" '{print $1}'`
        #ORIG_FILE_PATTERN=${FILE_PATTERN}
        #FILE_PATTERN=`echo ${ORIG_FILE_PATTERN} | sed -e 's/FILE_DATE/'${CM_RUN_DATE}'/1' | sed -e 's/ENTITY_NAME/'${CM_ENTITY}'/1'`
        #echo ${FILE_PATTERN}
        #ABORT_IND=`echo ${SPLIT_INFO} | awk '{FS="|"; print $2}'`
        ABORT_IND=`echo ${SPLIT_INFO} | awk -F"|" '{print $2}'`
        #lets expand wildcards
        set +f
        if [ "${FILE_PATTERN}" == "CBI.*.OH*" ] && [ "$TODAY_DAY" == "SATURDAY" ]       #New Line, Check if today is Saturday and AO FE files are being checked
        then                                                                            #New Line
                echo `date`": Info:         Skipping AO FE File check because of weekend batch run"
        elif [ ! -f ${PROCESS_DIR}/${FILE_PATTERN} ]                                    #Changed from if to elif
        then
                if [ "${ABORT_IND}" == "Y" ]
                then
                        fclean_up "Files (${FILE_PATTERN}) not found in ${PROCESS_DIR}."
                elif [ "${ABORT_IND}" == "N" ]
                then
                        file_alert "Files (${FILE_PATTERN}) not found in ${PROCESS_DIR}."
                else
                        echo `date`": Info:         Files (${FILE_PATTERN}) not found in ${PROCESS_DIR}, please configure File Watcher Plugin."
                fi
        else
                echo `date`": Info:         Completed checking Files (${FILE_PATTERN}) in ${PROCESS_DIR}"
        fi
done
echo `date`": Info:         Completed Checking File Pattern(s)"
clean_up
[ ${EXIT_FAILURE} -eq 1 ] && exit 9 || exit 0

But when its executed its throwing error like
Code:
/data/ds/dpr_ebicm_uat/etl/cm3_0/scripts/shell/cm_file_watcher.sh: line 145: [: too many arguments
/data/ds/dpr_ebicm_uat/etl/cm3_0/scripts/shell/cm_file_watcher.sh: line 145: [: too many arguments
/data/ds/dpr_ebicm_uat/etl/cm3_0/scripts/shell/cm_file_watcher.sh: line 145: [: too many arguments
/data/ds/dpr_ebicm_uat/etl/cm3_0/scripts/shell/cm_file_watcher.sh: line 145: [: /data/ds/dpr_ebicm_uat//etl/cm3_0/entities/BBME/process/CBI-PRODUCT.BBME.2011-06-05.csv.BBO.2011-06-05: binary operator expected
/data/ds/dpr_ebicm_uat/etl/cm3_0/scripts/shell/cm_file_watcher.sh: line 145: [: /data/ds/dpr_ebicm_uat//etl/cm3_0/entities/BBME/process/CBI-PROMOTION.BBME.2011-06-05.csv.BBO.2011-06-05: binary operator expected
/data/ds/dpr_ebicm_uat/etl/cm3_0/scripts/shell/cm_file_watcher.sh: line 145: [: /data/ds/dpr_ebicm_uat//etl/cm3_0/entities/BBME/process/CBI-PROMOTION.BBME.2011-06-05.csv.BBO.2011-06-05: binary operator expected

In the funtion line 145 is the one which is marked in bold in the above first code.
I am not able to figure out why is this error coming.
Can anyone please help me on this.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print Error with set command

I need to print some mandatory instructions if something fails in the script. I am using set -e to check and exit the script if some scripts/commands return non zero exit code. Is there any way to print these instructions with set command?? (0 Replies)
Discussion started by: Shribigb
0 Replies

2. Shell Programming and Scripting

set -o vi giving set: Syntax error

when trying : set -o vi getting error like- : set: Syntax error help me Double post (of sorts). Continue here. (0 Replies)
Discussion started by: RahulJoshi
0 Replies

3. Shell Programming and Scripting

awk command in script gives error while same awk command at prompt runs fine: Why?

Hello all, Here is what my bash script does: sums number columns, saves the tot in new column, outputs if tot >= threshold val: > cat getnon0file.sh #!/bin/bash this="getnon0file.sh" USAGE=$this" InFile="xyz.38" Min="0.05" # awk '{sum=0; for(n=2; n<=NF; n++){sum+=$n};... (4 Replies)
Discussion started by: catalys
4 Replies

4. HP-UX

What is the use of command set -- and set - variable?

Hi, I am using hp unix i want to know the use of the following commands set -- set - variable thanks (4 Replies)
Discussion started by: gomathi
4 Replies

5. UNIX for Dummies Questions & Answers

Running set options from the command line and bash command

I'm reading about debugging aids in bash and have come across the set command. It says in my little book that an addition to typing set you can also use them "on the command line when running a script..." and it lists this in a small table: set -o option Command Line... (5 Replies)
Discussion started by: Straitsfan
5 Replies

6. UNIX for Dummies Questions & Answers

Command line / script option to filter a data set by values of one column

Hi all! I have a data set in this tab separated format : Label, Value1, Value2 An instance is "data.txt" : 0 1 1 -1 2 3 0 2 2 I would like to parse this data set and generate two files, one that has only data with the label 0 and the other with label -1, so my outputs should be, for... (1 Reply)
Discussion started by: gnat01
1 Replies

7. Shell Programming and Scripting

Bash script set command to a variable

Hi, Will following set up work in bash script? I've got errors if assigning following binary command to a variable. But on the other hand, COMMAND="ls" works. Any explanation please? How can I assign binary command to a variable COMMAND then I can just call ${COMMAND}? COMMAND="rsync"... (3 Replies)
Discussion started by: hce
3 Replies

8. Shell Programming and Scripting

Help needed with shell script to search and replace a set of strings among the set of files

Hi, I am looking for a shell script which serves the below purpose. Please find below the algorithm for the same and any help on this would be highly appreciated. 1)set of strings need to be replaced among set of files(directory may contain different types of files) 2)It should search for... (10 Replies)
Discussion started by: Amulya
10 Replies

9. UNIX for Dummies Questions & Answers

Set Command to output a log of every command executed in the script

Hi Guys, I like to output every command executed in the script to a file. I have tried set -x which does the same. But it is not giving the logs of the child script which is being called from my script. Is there any parameters in the Set command or someother way where i can see the log... (2 Replies)
Discussion started by: mac4rfree
2 Replies
escape(1)							Mail Avenger 0.8.3							 escape(1)

NAME
escape - escape shell special characters in a string SYNOPSIS
escape string DESCRIPTION
escape prepends a "" character to all shell special characters in string, making it safe to compose a shell command with the result. EXAMPLES
The following is a contrived example showing how one can unintentionally end up executing the contents of a string: $ var='; echo gotcha!' $ eval echo hi $var hi gotcha! $ Using escape, one can avoid executing the contents of $var: $ eval echo hi `escape "$var"` hi ; echo gotcha! $ A less contrived example is passing arguments to Mail Avenger bodytest commands containing possibly unsafe environment variables. For example, you might write a hypothetical reject_bcc script to reject mail not explicitly addressed to the recipient: #!/bin/sh formail -x to -x cc -x resent-to -x resent-cc | fgrep "$1" > /dev/null && exit 0 echo "<$1>.. address does not accept blind carbon copies" exit 100 To invoke this script, passing it the recipient address as an argument, you would need to put the following in your Mail Avenger rcpt script: bodytest reject_bcc `escape "$RECIPIENT"` SEE ALSO
avenger(1), The Mail Avenger home page: <http://www.mailavenger.org/>. BUGS
escape is designed for the Bourne shell, which is what Mail Avenger scripts use. escape might or might not work with other shells. AUTHOR
David Mazieres Mail Avenger 0.8.3 2012-04-05 escape(1)
All times are GMT -4. The time now is 02:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy