简体   繁体   English

如果 shell 脚本失败,则从 sqlplus 提示符执行 shell 脚本并退出 sqlplus

[英]Execute shell script from sqlplus prompt and exit sqlplus if shell script fails

I am executing shell script from sqlplus console that checks for file and if file is not present it fails with exit code 1. Though, shell script fails, sqlplus doesn't exit and it starts running next scripts.我正在从 sqlplus 控制台执行 shell 脚本,该脚本检查文件,如果文件不存在,它会失败并出现退出代码 1。虽然,shell 脚本失败,sqlplus 不会退出并开始运行下一个脚本。

Can you amend your shell script?你能修改你的 shell 脚本吗? Have it let SQL Plus know the resultant state, eg让它让 SQL Plus 知道结果 state,例如

Shell
=====
Does normal work.
if [ shell level error ] then
  echo "pro File not found" > /tmp/sqlplus.status
  echo "exit" >> /tmp/sqlplus.status
else
  echo "pro Continuing on" > .status
fi

SQL Plus
========
host my_shell.sh
@/tmp/sqlplus.status

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM