Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有办法用python脚本启动java服务器?_Java_Python_Terminal_Subprocess - Fatal编程技术网

有没有办法用python脚本启动java服务器?

有没有办法用python脚本启动java服务器?,java,python,terminal,subprocess,Java,Python,Terminal,Subprocess,我有一段当前在终端中运行的代码,但我要自动化它,并使用子流程从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/clientpor

我有一段当前在终端中运行的代码,但我要自动化它,并使用子流程从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 –
Traceback(最近一次调用):文件“/Users/emmanuel/Documents/Selenium/sub.py”,第3行,在subprocess.Popen(“bin/run.sh root/conf.yaml”,cwd=“/Users/emmanuel/Documents/Sigma IB API/clientportal.gw/”)文件“/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess”,第947行,在init self(args,executable,preexec_fn,close_fds,File”/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py),第1819行,在_execute_child raise child_exception_类型(errno_num,err_msg,err_filename)–File”/Library/Frameworks/Python/Python.framework/framework/Versions/3.9/lib/python3.9/subprocess.py)中,第947行,在init
完成此过程后,我需要Java服务器保持运行,以便使用它