Stuck with Unexpected EOF


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Stuck with Unexpected EOF
# 1  
Old 06-21-2011
Bug Stuck with Unexpected EOF

Hi,

i have a script as below.

i'm using sun solaris 10.

Script :


Code:
#! /bin/sh
load() {
find /stage_area/loadfiles/telsims/test/ -type f -name "*$1" -print > /tmp/testfile.txt
fc=`cat /tmp/testfile.txt | wc -l | sed 's/ //g'`
if [ $fc = 0 ]; then
echo " Files Not Avaliable"
exit
else
#Count the Total Number of files in source folder and assign it to i
i=` ls -l /stage_area/loadfiles/telsims/test/*."$1" | wc -l | sed 's/ //g'`
# checking the condition that all file are avaliable or not
if [ $i =39 ]; then
while true
do
# checking if any data is still transfering thru FTP..
cp /stage_area/loadfiles/telsims/test/*."$1" /tmp/test
sleep 20
ls -l /stage_area/loadfiles/telsims/test/*."$1" | awk '{print $5}' > /export/home/pmutv/test/file1.txt
ls -l /tmp/test/*."$1" | awk '{print $5}' > /export/home/test/file2.txt
result=`cmp /export/home/pmutv/test/file1.txt /export/home/pmutv/test/file2.txt | cut -f3 -d" " | cut -f1 -d":"`
if [ $result = "differ" ]
then
echo " Transfer not yet completed-------->"
fstatus=incomplete
else
echo " Transfer Completed "
fstatus=complete
break;
fi
rm -rf /tmp/test/*."$1"
done
if [ $fstatus = "complete" ]
then
echo "Files Avalaible, Load Process is Starting Now" #| mailx -s "File Found" <email_removed> 
find /export/home/time/ -type f -name *.flg -print > /tmp/tmpfile.txt
Flf=`cat /tmp/tmpfile.txt | wc -l`
if [ "$Flf" = 1 ]; then
mv /export/home/time/*.flg /export/home/time/"$1".flg
fi
# Invoke script to start moving data to staging area /stage_area/pm/script/ImportsimCp.sh ControlSimTest.sh $1
# after successful completion do the todays load
 
while true
do
find /export/home/data -type f -name *.log -print > /tmp/test.txt
op=`cat /tmp/test.txt | cut -f5 -d"/"`
echo "$op"
if [ $op = "smLoadSimAktivitetMan.log" ]; then
echo "Log File Avaliable------> prev sess completed"
Today_Date=`date +"%y%m%d"`
DailyLoad $Today_Date
else
echo "Log file not available---> Prev Sess is on Process"
fi
done
fi
else
echo "Currently $i files are present" #| mailx -s "All files are not found" <email_removed> 
fi
fi
}
DailyLoad()
{
find /export/home/test/ -type f -name "*.$1" -print > /tmp/testfile.txt
Fcount=`cat /tmp/testfile.txt | wc -l`
if [ $Fcount = 0 ]; then
echo " Files Not Avaliable"
exit
 
#Count the Total Number of files in the testfile and assign it to i
 
# i=` ls -l /export/home/test/*."$1" | wc -l | sed 's/ //g'`
 
elif [ $Fcount = 39 ]; then
while true
do
cp /export/home/test/*."$1" /tmp/test
sleep 30
ls -l export/home/pmutv/*."$1" | awk '{print $5}' > /export/home/file1.txt
ls -l /tmp/test/*."$1" | awk '{print $5}' > /export/home/file2.txt
result=`cmp /export/home/file1.txt /export/home/file2.txt | cut -f3 -d" " | cut -f1 -d":"`
# echo "$result"
if [ $result = "differ" ]
then
echo " $1 Transfer not yet completed-------->"
else
echo " $1 Transfer Completed "
rm -rf /tmp/test/*."$1"
break;
fi
done
# checking the condition that all file are avaliable or not
echo "Files Avalaible, Load Process is Starting Now" #| mailx -s "File Found" <email_removed> 
   #Create a time stamp File with Today's date for controlling schedule / rename the existing file
              find /export/home/time/ -type f -name *.flg -print > /tmp/tmpfile.txt
              Flf=`cat /tmp/tmpfile.txt | wc -l`
              if [ $Flf != 0 ];then
                    mv /export/home/time/*.flg /export/home/time/"$1.flg
             fi

          # Invoke script to start moving data to staging area  /stage_area/pm/script/ImportsimCp.sh ControlSimTest.sh $Date
   else
            echo "Currently $Fcount files are present" #| mailx -s "All files are not found" <email_removed> 
 fi
}
#Consider today date as 25 May... the script will work under below scenario
#Scenario1:believing that 22nd load was completed on 23. 23 and 24 load was avaiable only on 25
#Scenario2:believing that 23rd load was completed on 24 and 24 load was avaiable only on 25

Today_Date=`TZ=GMT+24 date "+%Y%m%d"`  #25
prev_day=`TZ=GMT+24 date "+%Y%m%d"`  #24
day_to_previous=`TZ=GMT+48 date "+%Y%m%d"`  #23
back_log=`TZ=GMT+72 date "+%Y%m%d"`  #22

# below code is to get the last session date from informatica repository
ORACLE_VALUE=$prev_day
 
if [ $ORACLE_VALUE = $day_to_previous ]
          then
                business_tabel_VALUE=$back_log
 
        if [ $business_tabel_VALUE = $back_log ]
          then
             load $prev_day
        fi

elif[ $ORACLE_VALUE = $prev_day ]
   then
        business_tabel_VALUE=$day_to_previous

         if [ $business_tabel_VALUE = $day_to_previous ]
           then
               DailyLoad $Today_Date
         fi

  fi


Last edited by radoulov; 06-21-2011 at 04:43 AM.. Reason: Code tags!
# 2  
Old 06-21-2011
DailyLoad()
{

is not closed with }

Always post your code inside the [code] tag

it is easy to read
# 3  
Old 06-21-2011
When performing numeric condition checks use -eq equal, -ge greater than or equal, -gt greater than etc and leave a space around -eq or -ge etc. For string conditions check use =, != etc Sample example below..
Code:
if [ "$i" -eq 39 ]... # Numeric comparison
if [ "Ux" != "UX" ] ..

# String comparison
# 4  
Old 06-21-2011
Bug

i'm getting error as follows while running this script.
Smilie


line 158: unexpected EOF while looking for matching `"'
line 222: syntax error: unexpected end of file
# 5  
Old 06-21-2011
add -x in the shebang line and execute and tell me the error message and you didnt post the full code.

Code:
 
#!/bin/sh -x

# 6  
Old 06-21-2011
Hi,

The entire code and error message as follows.

Code:
#! /bin/sh -x
load() {
find /stage_area/loadfiles/telsims/test/ -type f -name "*$1" -print > /tmp/testfile.txt
fc=`cat /tmp/testfile.txt | wc -l | sed 's/ //g'`
if [ "$fc" -eq 0 ]; then
echo " Files Not Avaliable"
exit
else
#Count the Total Number of files in source folder and assign it to i
i=` ls -l /stage_area/loadfiles/telsims/test/*."$1" | wc -l | sed 's/ //g'`
# checking the condition that all file are avaliable or not
if [ "$i" -eq 39 ]; then
while true
do
# checking if any data is still transfering thru FTP..
cp /stage_area/loadfiles/telsims/test/*."$1" /tmp/test
sleep 20
ls -l /stage_area/loadfiles/telsims/test/*."$1" | awk '{print $5}' > /export/home/pmutv/test/file1.txt
ls -l /tmp/test/*."$1" | awk '{print $5}' > /export/home/test/file2.txt
result=`cmp /export/home/pmutv/test/file1.txt /export/home/pmutv/test/file2.txt | cut -f3 -d" " | cut -f1 -d":"`
if [ "$result" = "differ" ]
then
echo " Transfer not yet completed-------->"
fstatus=incomplete
else
echo " Transfer Completed "
fstatus=complete
break;
fi
rm -rf /tmp/test/*."$1"
done
if [ "$fstatus" = "complete" ]
then
echo "Files Avalaible, Load Process is Starting Now" #| mailx -s "File Found" venkat.ratnakaram@logica.com
find /export/home/time/ -type f -name *.flg -print > /tmp/tmpfile.txt
Flf=`cat /tmp/tmpfile.txt | wc -l`
if [ "$Flf" -eq 1 ]; then
mv /export/home/time/*.flg /export/home/time/"$1".flg
fi
# Invoke script to start moving data to staging area /stage_area/pm/script/ImportsimCp.sh ControlSimTest.sh $1
# after successful completion do the todays load
 
while true
do
find /export/home/data -type f -name *.log -print > /tmp/test.txt
op=`cat /tmp/test.txt | cut -f5 -d"/"`
echo "$op"
if [ "$op" = "smLoadSimAktivitetMan.log" ]; then
echo "Log File Avaliable------> prev sess completed"
Today_Date=`date +"%y%m%d"`
DailyLoad $Today_Date
else
echo "Log file not available---> Prev Sess is on Process"
fi
done
fi
else
echo "Currently $i files are present" #| mailx -s "All files are not found" venkat.ratnakaram@logica.com
fi
fi
}
DailyLoad()
{
find /export/home/test/ -type f -name "*.$1" -print > /tmp/testfile.txt
Fcount=`cat /tmp/testfile.txt | wc -l`
if [ "$Fcount" -eq 0 ]; then
echo " Files Not Avaliable"
exit
 
#Count the Total Number of files in the testfile and assign it to i
 
# i=` ls -l /export/home/test/*."$1" | wc -l | sed 's/ //g'`
 
elif [ "$Fcount" -eq 39 ]; then
while true
do
cp /export/home/test/*."$1" /tmp/test
sleep 30
ls -l export/home/pmutv/*."$1" | awk '{print $5}' > /export/home/file1.txt
ls -l /tmp/test/*."$1" | awk '{print $5}' > /export/home/file2.txt
result=`cmp /export/home/file1.txt /export/home/file2.txt | cut -f3 -d" " | cut -f1 -d":"`
# echo "$result"
if [ "$result" = "differ" ]
then
echo " $1 Transfer not yet completed-------->"
else
echo " $1 Transfer Completed "
rm -rf /tmp/test/*."$1"
break;
fi
done
# checking the condition that all file are avaliable or not
 
echo "Files Avalaible, Load Process is Starting Now" #| mailx -s "File Found"
#Create a time stamp File with Today's date for controlling schedule / rename the existing file
find /export/home/time/ -type f -name *.flg -print > /tmp/tmpfile.txt
Flf=`cat /tmp/tmpfile.txt | wc -l`
if [ "$Flf" -neq 0 ];then
mv /export/home/time/*.flg /export/home/time/"$1.flg
fi
 
# Invoke script to start moving data to staging area /stage_area/pm/script/ImportsimCp.sh ControlSimTest.sh $Date
else
echo "Currently $Fcount files are present" #| mailx -s "All files are not found" venkat.ratnakaram@logica.com
fi
}
#Consider today date as 25 May... the script will work under below scenario
#Scenario1:believing that 22nd load was completed on 23. 23 and 24 load was avaiable only on 25
#Scenario2:believing that 23rd load was completed on 24 and 24 load was avaiable only on 25
 
Today_Date=`TZ=GMT+24 date "+%Y%m%d"` #25
prev_day=`TZ=GMT+24 date "+%Y%m%d"` #24
day_to_previous=`TZ=GMT+48 date "+%Y%m%d"` #23
back_log=`TZ=GMT+72 date "+%Y%m%d"` #22
 
# below code is to get the last session date from informatica repository
ORACLE_VALUE=$prev_day
 
if [ "$ORACLE_VALUE" = "$day_to_previous" ]
then
business_tabel_VALUE=$back_log
 
if [ "$business_tabel_VALUE" = "$back_log" ]
then
load $prev_day
fi
 
elif[ "$ORACLE_VALUE" = "$prev_day" ]
then
business_tabel_VALUE=$day_to_previous
 
if [ "$business_tabel_VALUE" = "$day_to_previous" ]
then
DailyLoad $Today_Date
fi
 
fi


:wq
"final.sh" 221 lines, 6108 characters
bash-3.00# ./final.sh
./final.sh: line 209: unexpected EOF while looking for matching `"'
./final.sh: line 222: syntax error: unexpected end of file

Last edited by apple2685; 06-21-2011 at 05:36 AM.. Reason: code tag
# 7  
Old 06-21-2011
just for your information

code tag should end with [/CODE]

---------- Post updated at 02:06 PM ---------- Previous update was at 02:02 PM ----------

your script shows as 221 lines, but you posted only 137 lines...

Code:
 
"final.sh" 221 lines, 6108 characters

And the error is there in 209 and 222
Code:
 
./final.sh: line 209: unexpected EOF while looking for matching `"'
./final.sh: line 222: syntax error: unexpected end of file

This User Gave Thanks to itkamaraj For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help for resolving Unexpected EOF while assigning value to variable

#!/bin/sh . /opt/ora/oracle/db/tech_st/11.2.3/PROD_proddb.env sqlplus -s "username/password" << EOF no='sqlplus -s username/password<<EOF set heading off set feedback off Select pt.user_concurrent_program_name report_name , OUTFILE_NAME report_path FROm apps.fnd_concurrent_programs_tl... (12 Replies)
Discussion started by: usman_oracle
12 Replies

2. Shell Programming and Scripting

Unexpected EOF while looking for matching `"'

I have a piece of Linux script. It tells me some syntax error. I couldn't find it. Please help me to identify them. Thanks. The code looks like this: export ORACLE_SID=MYDB export SPW=`cat /opt/oracle/scripts/.sys_pw_$ORACLE_SID` export check_arch=`sqlplus -s << EOF / as sysdba... (7 Replies)
Discussion started by: duke0001
7 Replies

3. Shell Programming and Scripting

eof unexpected while looking[...]

Hello I use opensuse build service to build packages (oh surprise !) I have integrate a command in a spec whose worked and now this exit with: unexpected EOF while looking for matching `"' Command: if \.").mk ]; then ln -s $(pwd)/mozilla/security/coreconf/Linux2.6.mk \ ... (5 Replies)
Discussion started by: posophe
5 Replies

4. UNIX for Dummies Questions & Answers

Unexpected EOF in .profile

When opening a new window under Terminal, got that message: Last login: Sun Oct 30 10:35:12 on ttys000 -bash: /Users/MyName/.profile: line 47: syntax error: unexpected end of file I tried several clues like using BBedit or emacs to get rid of it, nothing does. Maybe shell commands cut or... (1 Reply)
Discussion started by: shub22
1 Replies

5. Shell Programming and Scripting

unexpected EOF : BASH

i'm writing a bash script that uploads a file to my server but it keeps saying unexpected EOF... i cannot see the problem with it, and it worked before i edited the script to work on my ipod touch as well. Here is the troublsome code... if ; then tar -czf "file(Mac).tar.gz" "/folder" >... (11 Replies)
Discussion started by: DuskFall
11 Replies

6. UNIX for Dummies Questions & Answers

unexpected EOF

hello everyone...im having this problem with unexpected EOF with line 85 which is..i cant see whats wrong with it..can any1 plz help me out. read -p "$p1 please enter the number of tries you wish to have:" lifeline function main() { guessnum=0 read -p "Please enter if its sinle player game... (1 Reply)
Discussion started by: Freakhan
1 Replies

7. Shell Programming and Scripting

line 85: unexpected EOF while looking for matching `"'

hello everyone...im having this problem with unexpected EOF with line 85 which is..i cant see whats wrong with it..can any1 plz help me out. read -p "$p1 please enter the number of tries you wish to have:" lifeline function main() { guessnum=0 read -p "Please... (6 Replies)
Discussion started by: Freakhan
6 Replies

8. Shell Programming and Scripting

Unexpected EOF while looking for matching `"'

Hi everyone, I am trying to search for a string in a file that is partly made up of a variable. Here's the code: echo "parentCategory = $parentCategory" echo "parentCategoryFormatted = $parentCategoryFormatted" numUrlsFoundInParentCategory=`grep -c "<Topic r:id=\"Top\/World\/Français\/"... (2 Replies)
Discussion started by: BlueberryPickle
2 Replies

9. UNIX for Advanced & Expert Users

unexpected EOF

I ran the following scripts and everytime i get the errot as follows Line 54: unexpected EOF while looking for matching ',' line 57 syntex error unexpected end of file#!/bin/ksh set -x BKUP_DIR=/u03/backups/abu/nightly_backup LOG_FILE=/u03/backups/abu/backup.log ORACLE_HOME=... (9 Replies)
Discussion started by: manna
9 Replies

10. Shell Programming and Scripting

Unexpected eof error

Hi, I am newbie and am just trying to connect to oracle from shell script ,,,but I am getting the following error ./prog.sh: line 20: syntax error: unexpected end of file The scripts is : #!/bin/bash O=$IFS; IFS=","; while read a b c d do echo $c ... (6 Replies)
Discussion started by: thana
6 Replies
Login or Register to Ask a Question