1

This is the scenario I'm trying to achieve using Java API function: getRuntime

I have a sample python script, in the script after some functionality check, it require's some input from the user, this script I want to execute using getRuntime().exec() method. I know we can give command line arguments to the script through getRuntime().exec() method, but I'm not sure if the above scenario is possible using getRuntime().exec() method.

Is it possible to do it, please let me know?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Jitendar M
  • 633
  • 1
  • 10
  • 26
  • Tip: Read (and implement) *all* the recommendations of [When Runtime.exec() won't](http://www.javaworld.com/jw-12-2000/jw-1229-traps.html). Then ignore that it refers to `exec` and build the `Process` using a `ProcessBuilder`. – Andrew Thompson Jan 22 '14 at 09:16

1 Answers1

2

Runtime.exec() gives you a Process. you can read and write to that Process (using getOutputStream() and getInputStream(), which allows you to get what's output by your script and send it more information afterwards. See for example this other thread.

Community
  • 1
  • 1
JP Moresmau
  • 7,388
  • 17
  • 31