执行了以下代码,但没有在我的同事机器上打开我的mac os终端,并将退出代码恢复为1而不是0
Runtime runtime = Runtime.getRuntime();
String output= "";
String[] myCommand = null;
if(command.equals("open")) {
String[] openTerminal = new String[] {
//"/bin/bash", "-c",
"osascript -e 'tell application \"Terminal\" to do script \"" +
"echo Welcome to Tectonic" +"\"'"
};
myCommand = openTerminal;
}
try
{
Process p = runtime.exec(myCommand);
InputStream stdIn = p.getInputStream();
InputStreamReader isr = new InputStreamReader(stdIn);
BufferedReader br = new BufferedReader(isr);
String line = null;
int exitVal = p.waitFor();
if(exitVal==0) {
}
1条答案
按热度按时间rjjhvcjd1#
如果在
exec
之后添加以下内容,您将看到错误消息:或将stderr合并到stdout: