Hi all. I am working on a python script to manage a minecraft server. I would like to be able to open the server in a new command window, and when you stop it, it will not close the python window as well. I have extensively googled it, to no avail. Here is what I have so far.
import subprocess p = subprocess.Popen(args=['java', '-jar', 'minecraft_server.jar', 'nogui'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) print p.stderr.read() print p.stdout.read()
The problem is, I am able to enter commands, but there is no output. I have also tried.
import subprocess subprocess.call(['java', '-jar', 'minecraft_server.jar', 'nogui'])
This outputs, and functions normally, except that it outputs into the python window. Thanks.
Offline
Offline
drhelmi wrote:
Bump. Nobody?
bro dont bump after like 3 seconds
thats annoying
Offline
777w wrote:
drhelmi wrote:
Bump. Nobody?
bro dont bump after like 3 seconds
thats annoying
How was that 3 seconds???
More like 2 days xP
Last edited by imnotbob (2012-01-07 14:35:19)
Offline
imnotbob wrote:
777w wrote:
drhelmi wrote:
Bump. Nobody?
bro dont bump after like 3 seconds
thats annoyingHow was that 3 seconds???
More like 2 days xP
oh was it
oh sorry i thought it was posted like today
Offline
777w wrote:
imnotbob wrote:
777w wrote:
bro dont bump after like 3 seconds
thats annoyingHow was that 3 seconds???
More like 2 days xPoh was it
oh sorry i thought it was posted like today
lol no
Oh well
drhelmi got a nice warning for the future.
Offline
goes in AT
Offline
I tried to do this before, with the same problem as you. Here's as far as I got:
process = subprocess.Popen('java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui', shell='/bin/bash', stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
I think you should then be able to read the output straight into Python with:
process.stdout.read()
...but that didn't work for me. Let me know if it does...
That's probably as close as you can get; if you really need a separate command window, you could create one in Python using something like Tkinter and send all the output there.
Hope that helps a little
Offline