PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, August 16, 2022

[FIXED] How to get past a window prompt while calling a subprocess

 August 16, 2022     input, output, python, python-3.x, subprocess     No comments   

Issue

I have a jar file that I want to run in the command line and collect it's stdout with a python script.

I make the call as a subprocess like:

def get_output():
  process = subprocess.run(['java', '-jar', 'myjar.jar', 'myfileargument'])

But a warning prompt comes up that I am unable to disable, which pauses execution until a user clicks 'OK' or presses enter. Is there a way to essentially 'click ok' in the prompt window that comes up via code and let the python script continue?


Solution

If there is no way for you, only using environment variables and parameters to the subprocess, to disable that warning, there is no easy way to do it.

Either you will have to go the road of UI automation, as mentionned by @furas in the comments. It may be relatively easy to do so given the multiple tools/frameworks there is to do that.

Or you may "patch" the jar to not require this warning. If you can replace the annoying .class file by another which will not require to accept the warning, it may be somewhat efficient. Or else you could install a custom ClassLoader in the java program, but it may prove to be difficult.



Answered By - Lenormju
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing