By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,611 Members | 891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,611 IT Pros & Developers. It's quick & easy.

Script error

P: 16
Hi,

Can anyone help me on the error message ? ; -)
recover.sh: line 18: syntax error: unexpected end of file
==================================
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/sh
  2. HostName=`hostname`
  3. LOGDIR=$PWDLE_SID
  4. LOGFILE=$LOGDIR/${MYSID}
  5. num=0
  6. while [$num -lt 10]
  7. do
  8. echo -n $num
  9. num='expr $num+1'
  10. sqlplus /nolog <<EOF
  11. conn / as sysdba
  12. recover datafile $num;
  13. exit
  14. done
  15.  
Thanks & Regards,
Vinod Sadanandan
Oracle DBA
Oct 19 '07 #1
Share this Question
Share on Google+
3 Replies

numberwhun
Expert Mod 2.5K+
P: 3,503
Hi,

Can anyone help me on the error message ? ; -)
recover.sh: line 18: syntax error: unexpected end of file
==================================
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/sh
  2. HostName=`hostname`
  3. LOGDIR=$PWDLE_SID
  4. LOGFILE=$LOGDIR/${MYSID}
  5. num=0
  6. while [$num -lt 10]
  7. do
  8. echo -n $num
  9. num='expr $num+1'
  10. sqlplus /nolog <<EOF
  11. conn / as sysdba
  12. recover datafile $num;
  13. exit
  14. done
  15.  
Thanks & Regards,
Vinod Sadanandan
Oracle DBA
Well, you have a here document , line 10 above, that tells the script to do all of the commands that follow until you see "EOF" on a line by itself. if that is the case, then you have not met the requirements of the here document. You need to have EOF on a line by itself, I assume, right before the word "exit".

Regards,

Jeff
Oct 19 '07 #2

P: 16
Hi Jeff ,

Thanks for the turn around,changed it like this,

Expand|Select|Wrap|Line Numbers
  1. funct_get_datafiles(){
  2. #Get the list of datafiles
  3. echo "Getting datafiles list " >> ${DATAFILES}
  4. file_list='{ORACLE_BASE}/sqlplus -s <<EOF
  5. /as sysdba
  6. set heading off  feedback off
  7. select distinct file_id from dba_data_files order by file_id;
  8. exit
  9. EOF'
  10. echo "####### DATE :" 'date'  > ${RECOVER}
  11. for datafile in 'echo $file_list'
  12. do
  13. ${ORACLE_BASE}/sqlplus -s <<EOF
  14. /as sysdba
  15. set heading off feedback off
  16. recover datafile ${file_list};
  17. exit
  18. EOF
  19. }
  20.  
Thanks & Redagrds,
Vinod Sadanandan
Oracle DBA
Oct 23 '07 #3

numberwhun
Expert Mod 2.5K+
P: 3,503
Hi Jeff ,

Thanks for the turn around,changed it like this,

Expand|Select|Wrap|Line Numbers
  1. funct_get_datafiles(){
  2. #Get the list of datafiles
  3. echo "Getting datafiles list " >> ${DATAFILES}
  4. file_list='{ORACLE_BASE}/sqlplus -s <<EOF
  5. /as sysdba
  6. set heading off  feedback off
  7. select distinct file_id from dba_data_files order by file_id;
  8. exit
  9. EOF'
  10. echo "####### DATE :" 'date'  > ${RECOVER}
  11. for datafile in 'echo $file_list'
  12. do
  13. ${ORACLE_BASE}/sqlplus -s <<EOF
  14. /as sysdba
  15. set heading off feedback off
  16. recover datafile ${file_list};
  17. exit
  18. EOF
  19. }
  20.  
Thanks & Redagrds,
Vinod Sadanandan
Oracle DBA
Vinod,

I am glad that the solution worked for you. In the future, when you post code to the forums, please remember to place [code] [/code] tags around the code so the moderators don't have to follow up behind you and add them.

Thank you!

Regards,

Jeff
Oct 23 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.