Bash verion 4.2.4 on RHEL 7.9
19c SQL*Plus
I have sql scripts script1.sql, script2.sql and script3.sql
as shown below.
After the execution of each script, I want to pause and wait for user to enter any key to proceed.
To achieve this, I tried the following 3 methods. None of them worked, even variant 3. Every time, all the 3 scripts get executed.
It seems, you cannot control anything in shell's heredoc (standard input, I suppose)
Any workaround for this ?
Variant 1
#!/bin/bash
sqlplus / as sysdba <<-EOF
@script1.sql
SET PAUSE ON
SET PAUSE 'Press Return to Continue'
@script2.sql
SET PAUSE ON
SET PAUSE 'Press Return to Continue'
@script3.sql
SET PAUSE ON
SET PAUSE 'Press Return to Continue'
exit
EOF
printf "SQL script executions are complete\n"
Variant 2
#!/bin/bash
sqlplus / as sysdba <<-EOF
@script1.sql
accept foo char prompt "Press [Enter] to continue : "
@script2.sql
accept foo char prompt "Press [Enter] to continue : "
@script3.sql
accept foo char prompt "Press [Enter] to continue : "
exit
EOF
printf "SQL script executions are complete\n"
Variant 3
#!/bin/bash
sqlplus / as sysdba <<-EOF
@script1.sql
!read -p "Press [Enter] key to continue..."
@script2.sql
!read -p "Press [Enter] key to continue..."
@script3.sql
!read -p "Press [Enter] key to continue..."
exit
EOF
printf "SQL script executions are complete\n"