Skip to content

Instantly share code, notes, and snippets.

@Spitfire1900
Created April 13, 2016 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Spitfire1900/181d4fde57131cf2d4ae0b900d080e90 to your computer and use it in GitHub Desktop.
Save Spitfire1900/181d4fde57131cf2d4ae0b900d080e90 to your computer and use it in GitHub Desktop.
from java.lang import ProcessBuilder
from java.lang.ProcessBuilder import Redirect
builder = ProcessBuilder(["fairymax"])
builder.redirectInput(Redirect.INHERIT)
builder.redirectOutput(Redirect.INHERIT)
builder.redirectError(Redirect.INHERIT)
builder.start().waitFor()
#### OUTPUT ####
#tellics say Fairy-Max 4.8V
#tellics say by H.G. Muller
#tellics say Gothic Chess is protected by U.S. patent #6,481,716 by Ed Trice.
#tellics say Falcon Chess is protected by U.S. patent #5,690,334 by George W. Duke
#program hangs here, occasionally you can provide stdin but then you get a name undefined error.
@Spitfire1900
Copy link
Author

In Python this is synonymous with:

import subprocess
def startProcess(cmd):
        proc = subprocess.Popen(cmd)
        proc.communicate()
        return proc
startProcess("fairymax")

This also does not work in Jython.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment