shell脚本中判断python命令执行结果
python脚本main.py
import sysdef main():try:"执行相关操作"sys.exit(0)except Exception as e:print(e)sys.exit(1)if __name__ == '__main__':main()
shell脚本
python main.pyif [ $? -eq 0 ];thenecho "python 代码执行成功。"elseecho "python 代码执行出错。"fi
时间:2019-02-02 00:59:21
python脚本main.py
import sysdef main():try:"执行相关操作"sys.exit(0)except Exception as e:print(e)sys.exit(1)if __name__ == '__main__':main()
shell脚本
python main.pyif [ $? -eq 0 ];thenecho "python 代码执行成功。"elseecho "python 代码执行出错。"fi
Shell脚本中获取命令运行结果 特殊变量使用 条件判断等常用操作
2021-12-06
shell中返回值是1为真还是假_shell脚本中判断上一个命令是否执行成功
2022-12-08
linux命令 sh -s shell脚本中 if 判断时候-s是什么意思?
2022-08-10