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
RREP(1) 						      General Commands Manual							   RREP(1)

NAME
rrep - replace patterns in files. SYNOPSIS
rrep [OPTIONS] PATTERN REPLACEMENT [FILE...] DESCRIPTION
The rrep utility searches input FILEs for matches to a given PATTERN and replaces those matches by a given REPLACEMENT. The pattern is, by default, a basic regular expression. The replacement string may contain special characters to refer to portions of the matched pattern. Binary files are, by default, ignored. A file is regarded as binary if it contains the null character. OPTIONS
-E, --extended-regexp PATTERN is interpreted as an extended regular expression (ERE). -F, --fixed-strings PATTERN and REPLACEMENT are interpreted as fixed strings, not as regular expressions or escape sequences. -R, -r, --recursive Each directory that is given on the command line is processed recursively. Files and sub-directories starting with the . character are, by default, ignored. --include=FILE_PATTERN Only files are processed that match the pattern FILE_PATTERN, except for files that are specifically given on the command line. *, ?, and [...] can be used as wildcards in FILE_PATTERN. Wildcards and backslash characters can be quoted with . --exclude=FILE_PATTERN Files that match the pattern FILE_PATTERN will be skipped, except for files that are specifically given on the command line (using wildcard matching as described under --include). --exclude-dir=PATTERN Directories that match PATTERN will be skipped, except for files that are specifically given on the command line (using wildcard matching as described under --include). -V, --version Print the version number of rrep. -S SUFFIX, --suffix=SUFFIX Override default backup suffix. This option implicitly activates backups. -a, --all Files and sub-directories starting with the . character in recursively processed directories (see --recursive) are processed as well. -b Backup before overwriting files. The backup files are written into the directory of the original file. Equivalent to using --backup=existing. --backup[=CONTROL] Like -b but accepts a version control argument. The file name of the backup file is appended by a ~ character. The backup suffix is ~, unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup option or through the VERSION_CONTROL environment variable. Here are the values: none, off never make backups (even if --backup is given) numbered, t make numbered backups existing, nil numbered if numbered backups exist, simple otherwise simple, never always make simple backups --binary Do not ignore binary files. A file is regarded as binary if it contains the null character . --dry-run The replacement is just simulated. No file is actually modified. -e PATTERN, --regexp=PATTERN Use PATTERN for matching. This option can be used to specify a pattern beginning with -. -h, --help Display a help message that descibes the command line options and exit afterwards. -i, --ignore-case Case distinctions in PATTERN are ignored. --keep-times The original access and modification times of files and directories are restored after processing. -p REPLACEMENT, --replace-with=REPLACEMENT Use REPLACEMENT for substitution. --interactive Each time before a file is modified the user is prompted and can cancel the modification. -q, --quiet, --silent All normal output messages are suppressed. -s, --no-messages All error messages are suppressed. -w, --word-regexp Only those matches of PATTERN are replaced that match whole words. -x, --line-regexp Only those matches of PATTERN are replaced that match whole lines. EXIT STATUS
Exit status is 1 if any error occurs, 0 otherwise. AUTHOR
Written by Arno Onken. REPORTING BUGS
If you find a bug in rrep, please send electronic mail to <asnelt@asnelt.org>. Include the version number, which you can find by running rrep --version. Also include in your message the output that the program produced and the output you expected. If you have other questions, comments or suggestions about rrep, contact the author via electronic mail to <asnelt@asnelt.org>. The author will try to help you out, although he may not have time to fix your problems. COPYRIGHT
Copyright 2011 Arno Onken This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. SEE ALSO
Regular Manual Pages find(1), grep(1), sed(1), xargs(1), regex(7). TeXinfo Documentation The full documentation for rrep is maintained as a TeXinfo manual. If the info and rrep programs are properly installed at your site, the command info rrep should give you access to the complete manual. User Commands rrep 1.3.3 RREP(1)
All times are GMT -4. The time now is 05:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy