我的第一篇文章要温柔。
我有下面的脚本,它是从 RedHat 5.3 框中取出来备份 Oracle 数据库的。该脚本在 Redhat 5.3 机器上运行良好。然后,我将其用作在 centos 6.2 机器上备份 oracle 数据库的参考,并根据需要对其进行了修改。
#!/bin/bash
ORACLE_HOME="/u01/app/oracle/product/11.2.0/db_1"
NLS_LANG=AMERICAN_AMERICA.AR8ISO8859P6
BKDATE=`date "+%Y-%m-%d_%H-%M-%S"`
C1="system/password@dbname DIRECTORY=RMBACKUP SCHEMAS=USER1,USER2,USER3 DUMPFILE=dbname_"
C2="_full_pump.dmp LOGFILE=dbname_"
C3="_full_pump.log"
BKCMD=$C1$BKDATE$C2$BKDATE$C3
echo $C1
echo $C2
echo $C3
echo $BKDATE
echo $BKCMD
#run the exp backup
$ORACLE_HOME/bin/expdp $BKCMD
奇怪的行为是,当我执行脚本时,新行会导致找不到命令错误,并且连接被合并,如下所示。
system/password@dbname DIRECTORY=RMBACKUP SCHEMAS=USER1,USER2,USER3 DUMPFILE=dbname_
_full_pump.dmp LOGFILE=dbname_
_full_pump.log
2012-07-10_09-39-06
system/password@dbname DIRECTORY=RMBACKUP SCHEMAS=USER1,USER2,USER3 DUMPFI_full_pump.log39-06ILE=dbname_
/bin/expdp: No such file or directoryacle/product/11.2.0/db_1
与其他文本合并的日期不是错字,即回显输出。
我在开头添加了 set -x ,这是输出
+ ORACLE_HOME=$'/u01/app/oracle/product/11.2.0/db_1\r'
+ NLS_LANG=$'AMERICAN_AMERICA.AR8ISO8859P6\r'
++ date +%Y-%m-%d_%H-%M-%S
+ BKDATE=$'2012-07-10_10-27-45\r'
+ C1='system/password@dbname DIRECTORY=RMBACKUP SCHEMAS=USER1,USER2,USER3 DUMPFI'E=dbname_
' C2='_full_pump.dmp LOGFILE=dbname_
+ C3=_full_pump.log
+ BKCMD='system/password@dbname DIRECTORY=RMBACKUP SCHEMAS=USER1,USER2,USER3 DUM_full_pump.log'7-45ILE=dbname_
+ echo system/password@dbname DIRECTORY=RMBACKUP SCHEMAS=USER1,USER2,USER3 $'DUMPFILE=dbname_\r'
system/password@dbname DIRECTORY=RMBACKUP SCHEMAS=USER1,USER2,USER3 DUMPFILE=dbname_
+ echo _full_pump.dmp $'LOGFILE=dbname_\r'
_full_pump.dmp LOGFILE=dbname_
+ echo $'_full_pump.log\r'
_full_pump.log
+ echo $'2012-07-10_10-27-45\r\r'
2012-07-10_10-27-45
+ echo system/password@dbname DIRECTORY=RMBACKUP SCHEMAS=USER1,USER2,USER3 $'DUMPFILE=dbname_\r2012-07-10_10-27-45\r_full_pump.dmp' $'LOGFILE=dbname_\r2012-07-10_10-27-45\r_full_pump.log\r'
system/password@dbname DIRECTORY=RMBACKUP SCHEMAS=USER1,USER2,USER3 DUMPFILE=dbn_full_pump.log27-45ILE=dbname_
+ $'/u01/app/oracle/product/11.2.0/db_1\r/bin/expdp' system/password@dbname DIRECTORY=RMBACKUP SCHEMAS=USER1,USER2,USER3 $'DUMPFILE=dbname_\r2012-07-10_10-27-45\r_full_pump.dmp' $'LOGFILE=dbname_\r2012-07-10_10-27-45\r_full_pump.log\r'
/bin/expdp: No such file or directoryacle/product/11.2.0/db_1
等待回复...