Java Calling Python Script stuck on sudo password prompt
I am developing a Java application that calls a python script behind the scene.
This is the way i call my python script:
Runtime r = Runtime.getRuntime();
Process p = r.exe("/path/to/Python/script.py");
I can see that my python script running in the background using ps.
The script requires root privileges so sudo prompts for password.
I have seen 2 solutions for this:
- I开发者_运维技巧mport Python Module pExpect and fill sudo as it shows up.
- Add jython java module to my library.
Both of them are overhead to my application, i don't need to interact with the script, i just want it to run in the background.
Is there a way to pop SUDO in UI, so user will interact and continue?
Thanks.
Use gksudo in place of sudo. It automatically pops up a window asking for the password.
精彩评论