簡體   English   中英

將 Shell 腳本的存儲過程異常拋回調用者

[英]Throwing Shell script's Stored procedure Exception Back to the Caller

我有一個 Shell Script A,它調用 Shell Script B,它在其中調用 ISQL 中的存儲過程。 必須將 Shell 腳本 B 的存儲過程中的異常拋回原始 Shell 腳本 A。知道如何執行此操作嗎?

@narasimhakulkami:在 POSIX shell 腳本的上下文中拋出異常是什么意思? 除了對一些可能被接收進程捕獲的合適信號使用kill之外,沒有可用的異常機制。

你可以要求異常醒目過程中提供自己的PID的環境變量,然后做一個kill這個PID,但當然你不能用這個信號傳達任何附加信息(如精確的異常消息),它無論如何都會是一個糟糕的設計。

這是解決方案:

iSQL > $output_file
status='cat $output_file'
if [$status== "Login Failed"]; then
echo "Login Failed error"
elif  [$status== "Permission Denied"]; then
echo "Permission Denied error"
else [$status== "Connection error"]; then
echo "Connection Denied Error"
fi

 Or

$status='grep "permission denied" $tmp.txt | sed 'g/ /d' | cut -d":" -f2'
echo $status

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM