Script error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vinod Sadanandan
    New Member
    • Oct 2007
    • 16

    Script error

    Hi,

    Can anyone help me on the error message ? ; -)
    recover.sh: line 18: syntax error: unexpected end of file
    =============== =============== ====
    Code:
    #!/usr/bin/sh
    HostName=`hostname`
    LOGDIR=$PWDLE_SID
    LOGFILE=$LOGDIR/${MYSID}
    num=0
    while [$num -lt 10]
    do
    echo -n $num
    num='expr $num+1'
    sqlplus /nolog <<EOF
    conn / as sysdba
    recover datafile $num;
    exit
    done
    Thanks & Regards,
    Vinod Sadanandan
    Oracle DBA
    Last edited by numberwhun; Oct 19 '07, 11:51 AM. Reason: add code tags
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Originally posted by Vinod Sadanandan
    Hi,

    Can anyone help me on the error message ? ; -)
    recover.sh: line 18: syntax error: unexpected end of file
    =============== =============== ====
    Code:
    #!/usr/bin/sh
    HostName=`hostname`
    LOGDIR=$PWDLE_SID
    LOGFILE=$LOGDIR/${MYSID}
    num=0
    while [$num -lt 10]
    do
    echo -n $num
    num='expr $num+1'
    sqlplus /nolog <<EOF
    conn / as sysdba
    recover datafile $num;
    exit
    done
    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

    Comment

    • Vinod Sadanandan
      New Member
      • Oct 2007
      • 16

      #3
      Hi Jeff ,

      Thanks for the turn around,changed it like this,

      Code:
      funct_get_datafiles(){
      #Get the list of datafiles
      echo "Getting datafiles list " >> ${DATAFILES}
      file_list='{ORACLE_BASE}/sqlplus -s <<EOF
      /as sysdba
      set heading off  feedback off
      select distinct file_id from dba_data_files order by file_id;
      exit
      EOF'
      echo "####### DATE :" 'date'  > ${RECOVER}
      for datafile in 'echo $file_list'
      do
      ${ORACLE_BASE}/sqlplus -s <<EOF
      /as sysdba
      set heading off feedback off
      recover datafile ${file_list};
      exit
      EOF
      }
      Thanks & Redagrds,
      Vinod Sadanandan
      Oracle DBA
      Last edited by numberwhun; Oct 23 '07, 10:23 PM. Reason: add code tags, removal of personal advertising

      Comment

      • numberwhun
        Recognized Expert Moderator Specialist
        • May 2007
        • 3467

        #4
        Originally posted by Vinod Sadanandan
        Hi Jeff ,

        Thanks for the turn around,changed it like this,

        Code:
        funct_get_datafiles(){
        #Get the list of datafiles
        echo "Getting datafiles list " >> ${DATAFILES}
        file_list='{ORACLE_BASE}/sqlplus -s <<EOF
        /as sysdba
        set heading off  feedback off
        select distinct file_id from dba_data_files order by file_id;
        exit
        EOF'
        echo "####### DATE :" 'date'  > ${RECOVER}
        for datafile in 'echo $file_list'
        do
        ${ORACLE_BASE}/sqlplus -s <<EOF
        /as sysdba
        set heading off feedback off
        recover datafile ${file_list};
        exit
        EOF
        }
        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 &#91;code] &#91;/code] tags around the code so the moderators don't have to follow up behind you and add them.

        Thank you!

        Regards,

        Jeff

        Comment

        Working...