Stuck with Unexpected EOF


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

sorry for the previous mail..

Code:
 
1 #! /bin/sh -x
2
3 load() {
4
5 find /stage_area/loadfiles/telsims/test/ -type f -name "*$1" -print > /tmp/testfile.txt
6
7 fc=`cat /tmp/testfile.txt | wc -l | sed 's/ //g'`
8
9 if [ "$fc" -eq 0 ]; then
10
11 echo " Files Not Avaliable"
12 exit
13 else
14
15 #Count the Total Number of files in source folder and assign it to i
16
17 i=` ls -l /stage_area/loadfiles/telsims/test/*."$1" | wc -l | sed 's/ //g'`
18
19 # checking the condition that all file are avaliable or not
20
21 if [ "$i" -eq 39 ]; then
22
23 while true
24
25 do
26 # checking if any data is still transfering thru FTP..
27
28 cp /stage_area/loadfiles/telsims/test/*."$1" /tmp/test
29
30 sleep 20
31
32 ls -l /stage_area/loadfiles/telsims/test/*."$1" | awk '{print $5}' > /export/home/pmutv/test/file1.txt
33
34 ls -l /tmp/test/*."$1" | awk '{print $5}' > /export/home/test/file2.txt
35
36 result=`cmp /export/home/pmutv/test/file1.txt /export/home/pmutv/test/file2.txt | cut -f3 -d" " | cut -f1 -d":"`
37
38 if [ "$result" = "differ" ]
39 then
40 echo " Transfer not yet completed-------->"
41 fstatus=incomplete
42
43 else
44 echo " Transfer Completed "
45 fstatus=complete
46 break;
47 fi
48 rm -rf /tmp/test/*."$1"
49 done
50
51 if [ "$fstatus" = "complete" ]
52
53 then
54
55 echo "Files Avalaible, Load Process is Starting Now" #| mailx -s "File Found" venkat.ratnakaram@logica.com
56
57 find /export/home/time/ -type f -name *.flg -print > /tmp/tmpfile.txt
58
59 Flf=`cat /tmp/tmpfile.txt | wc -l`
60
61 if [ "$Flf" -eq 1 ]; then
62
63 mv /export/home/time/*.flg /export/home/time/"$1".flg
64
65 fi
66 # Invoke script to start moving data to staging area /stage_area/pm/script/ImportsimCp.sh ControlSimTest.sh $1
67
68 # after successful completion do the todays load
69
70
71 while true
72 do
73
74 find /export/home/data -type f -name *.log -print > /tmp/test.txt
75 op=`cat /tmp/test.txt | cut -f5 -d"/"`
76 echo "$op"
77
78 if [ "$op" = "smLoadSimAktivitetMan.log" ]; then
79 echo "Log File Avaliable------> prev sess completed"
80 Today_Date=`date +"%y%m%d"`
81 DailyLoad $Today_Date
82 else
83 echo "Log file not available---> Prev Sess is on Process"
84 fi
85 done
86 fi
87 else
88
89 echo "Currently $i files are present" #| mailx -s "All files are not found" venkat.ratnakaram@logica.com
90 fi
91 fi
92 }
93
94 DailyLoad()
95 {
96
97 find /export/home/test/ -type f -name "*.$1" -print > /tmp/testfile.txt
98
99 Fcount=`cat /tmp/testfile.txt | wc -l`
100
101 if [ "$Fcount" -eq 0 ]; then
102
103 echo " Files Not Avaliable"
104 exit
105
106
107 #Count the Total Number of files in the testfile and assign it to i
108
109
110 # i=` ls -l /export/home/test/*."$1" | wc -l | sed 's/ //g'`
111
112
113 elif [ "$Fcount" -eq 39 ]; then
114
115 while true
116 do
117 cp /export/home/test/*."$1" /tmp/test
118
119 sleep 30
120
121 ls -l export/home/pmutv/*."$1" | awk '{print $5}' > /export/home/file1.txt
122 ls -l /tmp/test/*."$1" | awk '{print $5}' > /export/home/file2.txt
123
124 result=`cmp /export/home/file1.txt /export/home/file2.txt | cut -f3 -d" " | cut -f1 -d":"`
125 # echo "$result"
126
127 if [ "$result" = "differ" ]
128 then
129 echo " $1 Transfer not yet completed-------->"
130 else
131 echo " $1 Transfer Completed "
132 rm -rf /tmp/test/*."$1"
133 break;
134 fi
135
136 done
137
138 # checking the condition that all file are avaliable or not
139
140 echo "Files Avalaible, Load Process is Starting Now" #| mailx -s "File Found" root@xyz.com
141
142 #Create a time stamp File with Today's date for controlling schedule / rename the existing file
143
144 find /export/home/time/ -type f -name *.flg -print > /tmp/tmpfile.txt
145
146 Flf=`cat /tmp/tmpfile.txt | wc -l`
147
148 if [ "$Flf" -neq 0 ];then
149
150 mv /export/home/time/*.flg /export/home/time/"$1.flg
151 fi
152
153
154 # Invoke script to start moving data to staging area /stage_area/pm/script/ImportsimCp.sh ControlSimTest.sh $Date
155
156 else
157 echo "Currently $Fcount files are present" #| mailx -s "All files are not found" venkat.ratnakaram@logica.com
158
159 fi
160
161 }
162
163 #Consider today date as 25 May... the script will work under below scenario
164
165 #Scenario1:believing that 22nd load was completed on 23. 23 and 24 load was avaiable only on 25
166
167 #Scenario2:believing that 23rd load was completed on 24 and 24 load was avaiable only on 25
168
169
170 Today_Date=`TZ=GMT+24 date "+%Y%m%d"` #25
171
172 prev_day=`TZ=GMT+24 date "+%Y%m%d"` #24
173
174 day_to_previous=`TZ=GMT+48 date "+%Y%m%d"` #23
175
176 back_log=`TZ=GMT+72 date "+%Y%m%d"` #22
177
178
179 # below code is to get the last session date from informatica repository
180
181 ORACLE_VALUE=$prev_day
182
183
184
185 if [ "$ORACLE_VALUE" = "$day_to_previous" ]
186
187 then
188
189 business_tabel_VALUE=$back_log
190
191
192
193 if [ "$business_tabel_VALUE" = "$back_log" ]
194
195 then
196 load $prev_day
197
198 fi
199
200
201 elif[ "$ORACLE_VALUE" = "$prev_day" ]
202
203 then
204
205 business_tabel_VALUE=$day_to_previous
206
207
208 if [ "$business_tabel_VALUE" = "$day_to_previous" ]
209
210 then
211 DailyLoad $Today_Date
212
213 fi
214
215
216 fi

syntax error at line 217: `end of file' unexpected
# 9  
Old 06-21-2011
when ever you write code, arrange the code properly, so that easily to read and debug.

in the below code (see last), why fi is there and in the next line else is there ?

fi
else

Code:
if [ "$i" -eq 39 ]; then
 while true
 do
  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
 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

if [ "$i" -eq 39 ]; then
......

....
...
fi
else
# 10  
Old 06-22-2011
Hi,

That fi closes the used in this way

if [ "$i" -eq 39 ]; then
if [ "$fstatus" = "complete" ]; then
-----------
-----------
--------
fi
else
----------
fi
# 11  
Old 06-22-2011
execute the attached file and let me know

make sure there is a space after elif

Code:
 
elif [ "$ORACLE_VALUE" = "$prev_day" ]

# 12  
Old 06-22-2011
Hi

it is giving the error...

./text.sh: syntax error at line 134: `end of file' unexpected

There are total of 133 lines...
# 13  
Old 06-22-2011
make sure there is a space after elif

Code:
 
elif [ "$ORACLE_VALUE" = "$prev_day" ]

and first line should be

Code:
#!/bin/sh -x

no space after #!
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