0

I have a linux console application which behaves in a similar way to bash in that it receives commands while it's running in the same way and I want to use it via Python (use python to send inputs and receive outputs to/from the application while it’s running).

The application in question is custom Minecraft server software, it does not appear to have a useable API/SDK for my needs

How would I be able to run it, capture its output and interact with it (Enter commands into the program) using Python code.

1 Answer 1

0

You can use os.sytem(command) to just run a command, or if you want the output then try subprocess.check_output(commands), which returns whatever is returned by bash. Pass a list of commands to this, for example, to run node index.js, you'd pass ["node", "index.js"]

Sign up to request clarification or add additional context in comments.

5 Comments

Yes, but how would I interact with it, sorry if not clear
what do you mean by that that isn't covered by my answer?
I don't understand how to pass commands while the program is running, it's a little bit like bash in which you can run commands in a similar way for example, the server software has a 'help' command and I would run it by first: running the server, then, in the shell that I ran the server in I would type 'help'
Your code would allow me to add arguments to the command, however, I do not believe it would be able to allow me to run commands/give inputs to the command application whilst it is running
yes I believe you are right, in which case I don't have an answer for you, sorry. However, this might cover your issue: stackoverflow.com/questions/1124884/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.