Linux 处理在bash脚本中调用的python文件的输出
这只是bash脚本编写乐趣的开始 由于某种原因,它总是返回Fail。。 我不知道为什么,我已经花了很长时间编写bash脚本,但这似乎不起作用Linux 处理在bash脚本中调用的python文件的输出,linux,bash,Linux,Bash,这只是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 如果有人能为我指出正确的方向,我将不胜感激
#!/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
如果您指的是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
非常感谢您的快速回复,我不敢相信事情会这么简单,事情总是这样的….:如果脚本使用sys.exitvalue,值为0表示成功,则效果更好;任何其他值都是失败的。然后你可以简单地说如果Hudson.py;然后……非常感谢您的快速回复,我不敢相信事情会如此简单,事情总是这样如果脚本使用sys.exitvalue,值为0表示成功,则效果更好;任何其他值都是失败的。然后你可以简单地说如果Hudson.py;然后