如何启动具有标准bash shell环境的java进程? [英] How do I launch a java process that has the standard bash shell environment?
本文介绍了如何启动具有标准bash shell环境的java进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经尝试过查看流程构建器,但我不确定如何在流程中获取bash环境。
I've tried looking into process builder, but I'm not sure how to source the bash environment into the process.
例如我正在使用以下是启动我的流程:
For example I'm using the following to launch my process:
Process p = new ProcessBuilder(args).start();
InputStream is = p.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
我想要我的标准shell环境(来自/ etc / profile,.bashrc等)来源于该过程。
And I'd like my standard shell environment (from /etc/profile, .bashrc, etc.) sourced to the process.
如果我没有使用正确的条款,我很抱歉 - 仍在学习java。
Sorry if I'm not using the right terms - still learning java.
提前感谢您的帮助!
推荐答案
您需要使用ProcessBuilder设置shell调用。执行如下命令:
You need to set up a shell invocation with ProcessBuilder. Execute a command like:
/bin/bash -l -c "The entire command line that you want to execute"
这篇关于如何启动具有标准bash shell环境的java进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文