这只是我将享受 bash 脚本乐趣的开始
由于某种原因,它总是返回 Fail
..
我不知道为什么,我已经花了很长时间编写 bash 脚本,但这似乎不起作用。
#!/bin/bash
python /var/lib/scripts/Hudson.py result
if test "$result" = "Success"
then
echo "Done"
else
echo "Fail"
fi
Python 文件返回 Success
或 Fail
如果有人能为我指明正确的方向,我将不胜感激。
谢谢罗伯特。
附言。 python 文件将 XLSM
文件转换为已正常工作的 CSV
。
最佳答案
如果你指的是 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
关于linux - 处理 bash 脚本中调用的 python 文件的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18214360/