开发者

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:

  1. I开发者_运维技巧mport Python Module pExpect and fill sudo as it shows up.
  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜