Chinaunix
标题:
EOF的问题
[打印本页]
作者:
零度冰水
时间:
2016-11-28 17:53
标题:
EOF的问题
代码如下
#!/usr/bin/env bash
set -e
source /assets/colorecho
source ~/.bashrc
alert_log="$ORACLE_BASE/diag/rdbms/orcl/$ORACLE_SID/trace/alert_$ORACLE_SID.log"
listener_log="$ORACLE_BASE/diag/tnslsnr/$HOSTNAME/listener/trace/listener.log"
pfile=$ORACLE_HOME/dbs/init$ORACLE_SID.ora
# monitor $logfile
monitor() {
tail -F -n 0 $1 | while read line; do echo -e "$2: $line"; done
}
trap_db() {
trap "echo_red 'Caught SIGTERM signal, shutting down...'; stop" SIGTERM;
trap "echo_red 'Caught SIGINT signal, shutting down...'; stop" SIGINT;
}
start_db() {
echo_yellow "Starting listener..."
monitor $listener_log listener &
lsnrctl start | while read line; do echo -e "lsnrctl: $line"; done
MON_LSNR_PID=$!
echo_yellow "Starting database..."
trap_db
monitor $alert_log alertlog &
MON_ALERT_PID=$!
sqlplus / as sysdba <<-EOF
pro Starting with pfile='$pfile' ...
startup;
alter system register;
exit 0
EOF
while read line; do echo -e "sqlplus: $line"; done
wait $MON_ALERT_PID
}
create_db() {
echo_yellow "Database does not exist. Creating database..."
date "+%F %T"
monitor $alert_log alertlog &
MON_ALERT_PID=$!
monitor $listener_log listener &
#lsnrctl start | while read line; do echo -e "lsnrctl: $line"; done
#MON_LSNR_PID=$!
echo "START DBCA"
dbca -silent -createDatabase -responseFile /assets/dbca.rsp
echo_green "Database created."
date "+%F %T"
change_dpdump_dir
touch $pfile
trap_db
kill $MON_ALERT_PID
#wait $MON_ALERT_PID
}
stop() {
trap '' SIGINT SIGTERM
shu_immediate
echo_yellow "Shutting down listener..."
lsnrctl stop | while read line; do echo -e "lsnrctl: $line"; done
kill $MON_ALERT_PID $MON_LSNR_PID
exit 0
}
shu_immediate() {
ps -ef | grep ora_pmon | grep -v grep > /dev/null && \
echo_yellow "Shutting down the database..." && \
sqlplus / as sysdba <<-EOF
set echo on
shutdown immediate;
exit 0
EOF
while read line; do echo -e "sqlplus: $line"; done
}
change_dpdump_dir () {
echo_green "Changind dpdump dir to /opt/oracle/dpdump"
sqlplus / as sysdba <<-EOF
create or replace directory data_pump_dir as '/opt/oracle/dpdump';
commit;
exit 0
EOF
while read line; do echo -e "sqlplus: $line"; done
}
chmod 777 /u01/oracle/dpdump
echo "Checking shared memory..."
df -h | grep "Mounted on" && df -h | egrep --color "^.*/dev/shm" || echo "Shared memory is not mounted."
if [ ! -f $pfile ]; then
create_db;
fi
start_db
复制代码
运行的时候老是报
warning: here-document at line 71 delimited by end-of-file (wanted `EOF')
line 97: syntax error: unexpected end of file 错误,不知道哪里的问题
作者:
songyc_2015
时间:
2016-11-28 23:43
回复
1#
零度冰水
sqlplus / as sysdba <<-EOF...
...
...
EOF
结束的EOF多了空格
作者:
零度冰水
时间:
2016-11-29 09:01
回复
2#
songyc_2015
谢谢,一个空格调了好久
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2