比如 java通过Process类执行 sudo cat /etc/profile 命令
需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我是想通过程序读取命令的返回值,不需要存取文件了
是将命令写成shell脚本,然后用java调用脚本执行,是这样的吗?好像大概明白你的意思了
为什么不直接读取文本。可以用 sh -c 包装一下
3Q
google是个好东西: http://stackoverflow.com/questions/18708087/how-to-execute-bash-command-with-sudo-privileges-in-java
http://stackoverflow.com/questions/5168755/execute-a-linux-shell-command-with-sudo-using-java-without-entering-the-requi
这个人比较懒,什么都没有填写!
发布评论
需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。