【发布时间】:2020-08-02 03:37:46
【问题描述】:
为了让某些软件运行,我需要 1. 运行将执行远程许可证管理的脚本, 2. 执行 shell 脚本来启动软件。我可以通过在带有 rlm 的目录中打开一个命令窗口来执行此操作,然后键入 ./rlm 以运行 Linux 可执行文件。然后我可以进入包含 shell 脚本的目录,在该位置打开一个终端并运行 ./myshell.sh。这将打开我的软件的 GUI。
我想使用单个 Python 脚本运行这些步骤。我试过了:
#change the working directory...
os.chdir(r'/opt/mysoftwarelocation')
#confirm location change...
print(os.getcwd() )
#run ./rlm...
os.system('./rlm')
此时我可以从 python 终端看到 rlm 正在运行。
然后我想运行下面的代码来运行 shell 脚本...
os.chdir(r'/opt/mysoftwarelocation/sumsubdirectory')
print(os.getcwd() )
os.system('./some.sh')
不幸的是,在 os.system('./rlm') 完成后,脚本会停止并且不会继续执行并且不会出现错误。 如何让脚本的第二部分在单个 Python 脚本中运行?
【问题讨论】:
标签: python-3.x shell ubuntu terminal