从 Oracle 并发程序运行 UNIX shell 脚本时出现问题
我正在尝试运行一个使用 Oracle 并发程序在 KSH shell 中构建的主机脚本。
我的测试脚本如下:
echo "System Parameters passed by Concurrent Manager"
echo "+--------------------------------------------+"
XXWIN_PROGRAM=$0
XXWIN_LOGIN=$1
XXWIN_USERID=$2
XXWIN_USERNAME=$3
XXWIN_REQUEST_ID=$4
echo "XXWIN_PROGRAM :"$XXWIN_PROGRAM
echo "XXWIN_LOGIN :"$XXWIN_LOGIN
echo "XXWIN_USERID :"$XXWIN_USERID
echo "XXWIN_USERNAME :"$XXWIN_USERNAME
echo "XXWIN_REQUEST_ID :"$XXWIN_REQUEST_ID
shift 4
echo ""
echo "User Parameters passed by Concurrent Manager"
echo "+------------------------------------------+"
echo "1 :"$1
echo "2 :"$2
echo "3 :"$3
echo "4 :"$4
echo "5 :"$5
echo "6 :"$6
echo "7 :"$7
echo "8 :"$8
echo "9 :"$9
echo ""
# Generic Script Begins
# Declaring Constants, Data File Path, Control File Path etc
CTL_FILE_NAME=$1 # Control File Name(s)
CTL_FILE_PATH=$2 # Control File Path
DATA_FILE_NAME=$3 # Data File Name(s)
DATA_FILE_PATH=$4 # Data File Path
COMPONENT_NAME=$5 # Interface Component Name
SEQ_VALIDATION=$6 # Sequence Name
SUPPORT_EMAIL= $7 # Support e-mail(s) List
# Printing the User Parameters
echo "1 :"$CTL_FILE_NAME
echo "2 :"$CTL_FILE_PATH
echo "3 :"$DATA_FILE_NAME
echo "4 :"$DATA_FILE_PATH
echo "5 :"$COMPONENT_NAME
echo "6 :"$SEQ_VALIDATION
echo "7 :"$SUPPORT_EMAIL
# Assigning the Archive, IN and Prog Dir Paths
ARCHIVE_DIR="$XXWIN_TOP/bin/TEMP/archive"
XXWIN_IN_DIR="$XXWIN_TOP/bin/TEMP/in"
XXWIN_PROG_DIR="$XXWIN_TOP"
# Printing the directories
echo "Archive Directory :" $ARCHIVE_DIR
echo "IN Directory :" $XXWIN_IN_DIR
echo "Program Directory :" $XXWIN_PROG_DIR
i=10
k=5
j=`expr $i + $k`
echo $j
echo $i
echo "Out of Concurrent Program"
Shell 脚本程序名称以“.prog”结尾
我正在使用以下参数运行并发请求:
程序正常完成,但我收到以下日志消息。
如果我使用 #!/usr/bin/ksh
程序会错误地完成,所以我运行的主机文件没有它。从日志中可以清楚地看出,当脚本中遇到空格时,它会抛出一个错误,提示“找不到命令”。另外,正如您所看到的,我正在做一个简单的加法,即使这样也没有被识别。
非常感谢在这方面的任何帮助。
谢谢 :)
I am trying to run a HOST script which I have build in KSH shell using an Oracle Concurrent Program.
My Test script is as follows:
echo "System Parameters passed by Concurrent Manager"
echo "+--------------------------------------------+"
XXWIN_PROGRAM=$0
XXWIN_LOGIN=$1
XXWIN_USERID=$2
XXWIN_USERNAME=$3
XXWIN_REQUEST_ID=$4
echo "XXWIN_PROGRAM :"$XXWIN_PROGRAM
echo "XXWIN_LOGIN :"$XXWIN_LOGIN
echo "XXWIN_USERID :"$XXWIN_USERID
echo "XXWIN_USERNAME :"$XXWIN_USERNAME
echo "XXWIN_REQUEST_ID :"$XXWIN_REQUEST_ID
shift 4
echo ""
echo "User Parameters passed by Concurrent Manager"
echo "+------------------------------------------+"
echo "1 :"$1
echo "2 :"$2
echo "3 :"$3
echo "4 :"$4
echo "5 :"$5
echo "6 :"$6
echo "7 :"$7
echo "8 :"$8
echo "9 :"$9
echo ""
# Generic Script Begins
# Declaring Constants, Data File Path, Control File Path etc
CTL_FILE_NAME=$1 # Control File Name(s)
CTL_FILE_PATH=$2 # Control File Path
DATA_FILE_NAME=$3 # Data File Name(s)
DATA_FILE_PATH=$4 # Data File Path
COMPONENT_NAME=$5 # Interface Component Name
SEQ_VALIDATION=$6 # Sequence Name
SUPPORT_EMAIL= $7 # Support e-mail(s) List
# Printing the User Parameters
echo "1 :"$CTL_FILE_NAME
echo "2 :"$CTL_FILE_PATH
echo "3 :"$DATA_FILE_NAME
echo "4 :"$DATA_FILE_PATH
echo "5 :"$COMPONENT_NAME
echo "6 :"$SEQ_VALIDATION
echo "7 :"$SUPPORT_EMAIL
# Assigning the Archive, IN and Prog Dir Paths
ARCHIVE_DIR="$XXWIN_TOP/bin/TEMP/archive"
XXWIN_IN_DIR="$XXWIN_TOP/bin/TEMP/in"
XXWIN_PROG_DIR="$XXWIN_TOP"
# Printing the directories
echo "Archive Directory :" $ARCHIVE_DIR
echo "IN Directory :" $XXWIN_IN_DIR
echo "Program Directory :" $XXWIN_PROG_DIR
i=10
k=5
j=`expr $i + $k`
echo $j
echo $i
echo "Out of Concurrent Program"
Shell Script program name ends with ".prog"
I am running the concurrent request with the following parameters:
The program completes normal but I am getting the following log messages.
If I am using #!/usr/bin/ksh
the program completes in error so I am running the host file with out that. From the log its clear that when ever a space is encountered in the script, its throwing an error saying "Command not found". Also as you can see that I am doing a simple addition, even that is also not recognized.
Any help in this regards is much appreciated.
Thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您是否碰巧使用 Windows 系统上的编辑器来创建脚本?它在每一行的末尾放置一个回车+换行符,而不是像 Unix 格式那样只包含一个换行符。这会扰乱脚本的执行。 Unix系统通常有一个像“dos2unix”这样的命令来转换文件。
如果不是这样,我会尝试从命令行手动运行脚本以确保它有效。
Did you happen to use an editor on a Windows system to create the script? It's puts a carriage return + line feed character at the end of every line instead of the Unix format of just having a line feed. That messes up the script execution. Unix systems usually have a command like "dos2unix" to convert the file.
If that's not it, I would try running the script manually from the command line to make sure it works.
当我尝试使用 CAT -vt读取文件时,我可以看到该文件包含特殊字符,例如 ^M 和 ^I。这可能是由于文件传输模式的原因(但我以ASCII模式传输,仍然出现特殊字符)。
我打开 VI 编辑器并粘贴相同的脚本。保存文件,尝试运行脚本,运行良好。
我还是没明白特殊字符是怎么出现的。我使用 notepad++ 作为我的编辑器。
When I tried to read the file using
CAT -vt <filename>
, I could see that the file contains special characters such as ^M and ^I. This may be because of the file transfer mode(but I transferred in ASCII mode, still the special characters where appearing).I opened a VI editor and pasted the same script. Save the file, tried to run the script, It was working fine.
I still didn't get how the special characters appeared. I used notepad++ as my editor.
当 VI 或 CAT 显示特殊字符时,与 Linux/Unix 兼容性的转换尚未完全完成。通常有很多解决方案,也许 Notepad++ 是这里的原因。也许不是。在操作系统本身上编写脚本不仅速度更快(不需要 FTP,这已经是一个很大的优点),而且您不必面对这些烦人的 control-M 字符。 ASCII 转换有时会失败。您也可以尝试其他 FTP 程序。或者如上所述,一起避免这一切。
When either VI or CAT displays specials characters, the conversion to Linux/Unix compatibility is not completely done. There's often many solutions, maybe Notepad++ is the cause here. Maybe not. Writing scripts on the OS itself, is not only faster (no need for FTP, which is already a big plus), but you don't have to face these annoying control-M characters. The ASCII conversion sometimes fails. You can also try another FTP program. Or avoid it all togheter, as mentioned above.
Notepad++可以将文件保存为Windows CRLF或Unix/Linux LF格式Notepad++编辑-EOL转换-选择Windows或Unix,然后保存。如果并发管理器足够聪明,可以在需要时为您转换它,那就太好了。
Notepad++ can save the file in Windows CRLF or Unix/Linux LF format Notepad++ Edit-EOL Conversion-Choose Windows Or Unix, and then save it. It would be nice if the concurrent manager were smart enough to convert it for you when needed.