Error in script for set command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error in script for set command
# 1  
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.
# 2  
Old 12-08-2011
Code:
if [ "${FILE_PATTERN}" == "CBI.*.OH*"  -a  "$TODAY_DAY" == "SATURDAY" ]

# 3  
Old 12-08-2011
Hi

You mean i will change the code in the if loop to the one which you have provided. What difference would it make by putting the -a option. Could you please explain me.
# 4  
Old 12-08-2011
Please help me to find time diff between two files

HI,

I am new user. I dont know how to enter new post. thats why i used post reply option.plz forgive me. my doubt is below.

file1:
ramki - 20:34:23
raja - 22:34:45

file2:
ramki - 22:34:45
raja - 23:34:56

i need output like:

ramki - 20:34:23 22:34:45 2:00:22
raja - 22:34:45 23:34:56 1:00:11

i need the time diff ffrom two files.Please help to me.its urgent.

---------- Post updated at 04:46 AM ---------- Previous update was at 04:36 AM ----------

plz reply for my question.. its urgent. i am waiting for any one reply.
# 5  
Old 12-08-2011
# 6  
Old 12-08-2011
Quote:
Originally Posted by vee_789
Hi

You mean i will change the code in the if loop to the one which you have provided. What difference would it make by putting the -a option. Could you please explain me.
I think there's some problem with the way your shell interprets if condition mentioned in your script (by the way, if-else -> conditional statements, not a loop). I'm not getting an error when I say this to my shell: if [ condition1 ] && [ condition2 ]. (I'm using GNU Bash, version 3.1.17)
May be you're using an older version of bash. Try one of the following options:

1. if [ condition1 -a condition2 ]
2. if [[ condition1 && condition2 ]]
# 7  
Old 12-08-2011
time diff between two files

HI,

I am new user. my doubt is below. please give the shell script any body know.

file1:
ramki - 20:34:23
raja - 22:34:45
.
.
.

file2:
ramki - 22:34:45
raja - 23:34:56
.
.
.
i need output like:

ramki - 20:34:23 22:34:45 2:00:22
raja - 22:34:45 23:34:56 1:00:11
.
.
.
i need the time diff ffrom two files.Please help to me.its urgent.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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. 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

7. 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

8. 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

9. 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
Login or Register to Ask a Question