I have a script like below. My goal is write to a log file terminating with the current date and time as filename and spool to the file:
#!/bin/bash
year=`date +%Y`
month=`date +%m`
day=`date +%d`
prefixe=$month$day$year
logfile="/home/oracle/logs/exec_proc_daily_20_"$prefixe.log
sqlplus / "as sysdba" <<EOF
spool on
spool $logfile
execute Proc_RFC_MAJ_MV_ITIN;
execute Proc_RFC_MAJ_MV_REFGEO;
commit;
quit
EOF
When I execute the script, the spool $logfile gives an error. No log is created. But it works when I use something like spool exec_proc_daily_2o.log. Why is the variable $logfile not replace.
sqlplus / "as sysdba"withcatand running your script suggests that the variable replacement is working as expected...