我有一段当前在终端中运行的代码,但是我要自动化它,并使用子进程从python运行这个命令。目标是为ibrestapi启动一个java服务器进行连接。
这些是我通常放在mac终端上的命令。。。
cd /Users/emmanuel/Documents/Sigma-IB-API/clientportal.gw/
为了改变我放进去的目录
bin/run.sh root/conf.yaml
这是我想要的输出。。。
cd /Users/emmanuel/Documents/Sigma-IB-API/clientportal.gw/
emmanuel@MacServer clientportal.gw % bin/run.sh root/conf.yaml
running
runtime path : root:dist/ibgroup.web.core.iblink.router.clientportal.gw.jar:build/lib/runtime/*
verticle :
-> mount demo on /demo
Java Version: 1.8.0_271
****************************************************
version: ed4af2592e9dd4a784d5403843bd18292fd441ea Fri, 9 Nov 2018 13:23:18 -0500
****************************************************
This is a Beta release of the Client Portal Gateway
for any issues, please contact api@ibkr.com
and include a copy of your logs
****************************************************
https://www.interactivebrokers.com/api/doc.html
****************************************************
Open https://localhost:5000 to login
App demo is available after you login under: https://localhost:5000/demo/
相反,当我使用子进程将其放入python中时,并没有得到期望的结果。这是把。。。
import subprocess
subprocess.Popen("bin/run.sh root/conf.yaml", cwd="/Users/emmanuel/Documents/Sigma-IB-API/clientportal.gw/")
这是我收到的但我不想要的结果
Traceback (most recent call last): File "/Users/emmanuel/Documents/Selenium/sub.py", line 3, in <module> subprocess.Popen("bin/run.sh root/conf.yaml", cwd="/Users/emmanuel/Documents/Sigma-IB-API/clientportal.gw/") File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 947, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1819, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) –File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 947, in init –
在我完成这个过程之后,我需要java服务器保持运行,以便我可以使用它
暂无答案!
目前还没有任何答案,快来回答吧!