shell脚本中beeline命令的返回代码

vjhs03f7  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(1249)

如何捕获在shell脚本中执行的beeline命令的返回代码。如下所示:
beeline-u$beeline-e“alter table drop if exists partition(date='');”
我想用shell脚本捕获上述查询的状态。
谢谢ag

6tqwzwtp

6tqwzwtp1#

$? 捕获上一条语句的返回代码。将结果存储在变量中或使用 $? 稍后进行更多处理。

beeline -u $Beeline -e "ALTER TABLE DROP if exists partition (date='');"
rc=$?

# do whatever with $rc here

相关问题