0

I have a bash script I've been using for ages. It has a few lines it just start/stop some jobs in database. It is very simple and it never fails. Last year, it facts in December so a few days ago :) I migrated whole data to a new machine. And then my problem starts. Now script works as it worked before but now it returns warning. Below output:

[oracle@SVMSLUATTIADB1 ~]$ ./batch.sh stop 
./batch.sh: line 87: warning: here-document at line 85 delimited by end-of-file (wanted `!')
./batch.sh: line 87: warning: here-document at line 85 delimited by end-of-file (wanted `!')

Batch_Executer_1                                   [NOT OK]

Batch_Executer_2                                   [NOT OK]

[oracle@SVMSLUATTIADB1 ~]$

The piece of code mentioned in warning is:

batch_stop()
{
  for BATCH in $BATCHES
  do
    SQLRES=`sqlplus -S "/ as sysdba" << !
      exec dbms_scheduler.disable('"AIT"."${BATCH}"', TRUE);
   `     << line 87
  done
}

So the question is how to avoid/hide this warnings. It is not critical, script works as it worked but the view of warning disturbs. I see that before I had bash version 3.2.25 but now it is bash 4.1.2.

I tried to modified my code and redirected output :

   {SQLRES=`sqlplus -S "/ as sysdba" << !
              exec dbms_scheduler.disable('"AIT"."${BATCH}"', TRUE);
           ` } 2>/dev/null

but it didn't help :(

user3863616
  • 185
  • 1
  • 9
  • 24

1 Answers1

1

The warning is caused by invalid here document syntax. Namely, the second limit word ("!") is missing.

Also, don't use back quotes for command substitution. Use the $(...) syntax instead, as it is more readable, and it can be nested.

The fixed version:

SQLRES=$(sqlplus -S "/ as sysdba" << !
exec dbms_scheduler.disable('"AIT"."${BATCH}"', TRUE);
!
)

Note, the here document ends on a line containing only the limit word (the exclamation mark, in particular). So it is not allowed to indent the second limit word, for example.

Ruslan Osmanov
  • 20,486
  • 7
  • 46
  • 60