$ cat getsums.sh
#!/usr/bin/sh
FILENAME=$1
DELIMITER=$2
FIRST_COL=$3
SECOND_COL=$4
SALESDATE_COL=$5
STOREID=$6
UPC=$7
GTIN=$8
PROMOID=$9
echo ""
echo ".:Summation Tool:."
for FILE in ${FILENAME}
do
gzip -t ${FILE} 2>/dev/null
if [ $? -eq 1 ];
then
comm=cat
else
comm=gzcat
fi
.
.
.
done
everytime i execute it, it keeps saying that the error is in "do"...
$ sh getsums.sh ft-GNCT-3398-CD-2012-07-07-140112.txt.gz
.:Summation Tool:.
getsums.sh[36]: ^M: not found.
' is not expected.ntax error at line 39 : `do
$ sh getsums.sh
.:Summation Tool:.
getsums.sh[36]: ^M: not found.
' is not expected.ntax error at line 39 : `do
$ sh getsums.sh ft-GNCT-3398-CD-2012-07-07-140112.txt.gz " " 22 23 1 2 4
.:Summation Tool:.
getsums.sh[36]: ^M: not found.
' is not expected.ntax error at line 39 : `do
can someone please explain me what is this error?
I think i was able to execute this script before, but somehow now.. it keeps having error like this. for your advise please. thanks guys
Seems carriage-return characters are in your file. How did you get this file? From a Windows machine? FTP? binary mode?
Use dos2unix utility on the file.
1) You don't list the line in question (36 or 39).
2) Looks like there is a <carriage return> (^M or \r or 0x0D) char in one of your parameters, probably $1.
im sorry if i dont understand your suggestion correctly.. is it like this?
$ sh getsums.sh -vx ft-GNCT-3398-CD-2012-07-07-140112.txt.gz " " 22 23 1 2 4
.:Summation Tool:.
getsums.sh[36]: ^M: not found.
' is not expected.ntax error at line 39 : `do
---------- Post updated at 05:34 AM ---------- Previous update was at 05:32 AM ----------