gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 17:22:40 25 4
gpt4 key购买 nike

我的第一篇文章是温柔的。

我有下面的脚本,它是从 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

等待回复...

最佳答案

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

关于bash - Oracle expdp CentOS 6.2 Shell 脚本异常行为 - 换行给出未找到的命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11408032/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com