gpt4 book ai didi

linux - 如何在 Shell 脚本中测试 ant 命令的输出?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:09:22 26 4
gpt4 key购买 nike

我需要测试“ant start”命令的输出是“Build success”还是“Build Fail”

我的代码是:

# Start the App
sleep 20
ant -f start
if [ ! $? = 0 ] || [ "Here I have to test if ant start command output was Build Success or Build Failure" ] ; then
echo "*** Failed to start"
Exit 2
fi

最佳答案

你可以这样做:

if ant -f start
then
echo "*** Build started"
else
echo "*** Failed to start"
Exit 2
fi

否则:

ant -f start
if [ $? -eq 0 ]
then
echo "*** Build started"
else
echo "*** Failed to start"
Exit 2
fi

关于linux - 如何在 Shell 脚本中测试 ant 命令的输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23272285/

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