2

这只是我对 bash 脚本的乐趣的开始,
出于某种原因它总是返回Fail..
而且我不知道为什么,我已经完成了 bash 脚本的 looooooooong 时间,但这并没有t 似乎工作。

#!/bin/bash

python /var/lib/scripts/Hudson.py result
if test "$result" = "Success"
then
     echo "Done"
else
     echo "Fail"
fi  

python 文件返回SuccessFail

如果有人能指出我正确的方向,那将不胜感激。

谢谢,罗伯特。
PS。python 文件将文件转换为已经正常工作的XLSM文件。CSV

4

1 回答 1

4

如果你的意思是 python 的输出,你应该用 $() 来测试它

#!/bin/bash

if test "$(python /var/lib/scripts/Hudson.py result)" = "Success"
then
     Run next command
else
     Exit the script
fi  

使用 [[ ]] 实际上会更好

#!/bin/bash

if [[ "$(python /var/lib/scripts/Hudson.py result)" == "Success" ]]
then
     Run next command
else
     Exit the script
fi  

如果您的意思是退出代码:

#!/bin/bash

if python /var/lib/scripts/Hudson.py result
then
     Run next command
else
     Exit the script
fi  
于 2013-08-13T16:32:10.703 回答