import subprocess
subprocess.run(['java','-jar','file.jar','*req_params_for_jar*'])
I am running this in a python shell using AWS glue. While running the jar file, it prints the accept license agreement on the logs and keeps waiting for an interactive input Y or yes. How can I pass this in the above code?
Try writing to stdin with subprocess.Popen
.
Code example, modified from your original code:
import subprocess
child = subprocess.Popen(['java', '-jar', 'file.jar','req_params_for_jar'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
child.stdin.write(b"Y")
print(child.communicate()[0])
child.stdin.close()
Try it online (grep example) here.