Shell 脚本:从 shell 脚本中执行 python 程序 [英] Shell Script: Execute a python program from within a shell script
本文介绍了Shell 脚本:从 shell 脚本中执行 python 程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试过在谷歌上搜索答案,但没有运气.
我需要使用我的作品超级计算机服务器,但是要运行我的 python 脚本,它必须通过 shell 脚本执行.
例如我想让 job.sh
执行 python_script.py
如何实现?
解决方案
只要确保 python 可执行文件在你的 PATH 环境变量中,然后添加到你的脚本中
python path/to/the/python_script.py
详情:
- 在文件job.sh中,把这个
#!/bin/sh蟒蛇 python_script.py
- 执行此命令以使脚本可以为您运行:
chmod u+x job.sh
- 运行它:
./job.sh
I've tried googling the answer but with no luck.
I need to use my works supercomputer server, but for my python script to run, it must be executed via a shell script.
For example I want job.sh
to execute python_script.py
How can this be accomplished?
解决方案
Just make sure the python executable is in your PATH environment variable then add in your script
python path/to/the/python_script.py
Details:
- In the file job.sh, put this
#!/bin/sh python python_script.py
- Execute this command to make the script runnable for you :
chmod u+x job.sh
- Run it :
./job.sh
这篇关于Shell 脚本:从 shell 脚本中执行 python 程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文