Oracle expdp CentOS 6.2 Shell脚本异常行为 - 新行给出命令未找到

时间:2012-07-10 06:49:14

标签: bash centos oracle11gr2 rhel5

我的第一篇文章很温柔​​。

下面的脚本是从RedHat 5.3框中取出来备份Oracle数据库的。该脚本在Redhat 5.3框上运行良好。然后我将它用作在centos 6.2盒子上备份oracle db的参考,并根据需要对其进行修改。

#!/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

等待回复...

1 个答案:

答案 0 :(得分:1)

如您所见,文本中有'\r'个字符。可能是您使用编辑器编辑了文件,该编辑器会自动在行尾添加\r。您必须再次编辑该文件并删除这些字符。