Python 在一起工作的两个脚本完成后,如何自动启动脚本?

Python 在一起工作的两个脚本完成后,如何自动启动脚本?,python,ubuntu,Python,Ubuntu,实际上,我用一个shell命令运行了两个python脚本,但是当它们完成后,如何自动运行第三个呢 你知道一个程序,我可以添加在相同的。sh这样做吗 对于我使用的.sh文件: python script1.py && python script2.py 我想在此序列之后运行script3.py。有人能帮我吗 (显然,我在终端上用 >chmod u+x shell.sh >./shell.sh

实际上,我用一个shell命令运行了两个python脚本,但是当它们完成后,如何自动运行第三个呢

你知道一个程序,我可以添加在相同的。sh这样做吗

对于我使用的.sh文件:

python script1.py && python script2.py
我想在此序列之后运行script3.py。有人能帮我吗

(显然,我在终端上用

>chmod u+x shell.sh   
>./shell.sh                                   

      

致以最诚挚的问候。

这将仅在前面所有脚本都成功的情况下执行每个后续脚本,也就是说,如果所有脚本都退出且状态为0。请记住在脚本之间添加
&

python script1.py && python script2.py && python script3.py
例如:

执行所有3个脚本:

$ python -c 'print(1); exit(0);' && python -c 'print(2); exit(0);' && python -c 'print(3); exit(0);'
1
2
3
$ python -c 'print(1); exit(0);' && python -c 'print(2); exit(1);' && python -c 'print(3); exit(0);'
1
2

仅执行前2个脚本:

$ python -c 'print(1); exit(0);' && python -c 'print(2); exit(0);' && python -c 'print(3); exit(0);'
1
2
3
$ python -c 'print(1); exit(0);' && python -c 'print(2); exit(1);' && python -c 'print(3); exit(0);'
1
2


“WundoAB”是什么意思?“不工作”?有什么错误信息吗?如果这回答了你的问题,考虑接受答案并投票。