我如何使用参数在 Java 中执行命令?
我试过了
Process p = Runtime.getRuntime().exec(new String[]{"php","/var/www/script.php -m 2"});
这是行不通的。
String[] options = new String[]{"option1", "option2"};
Runtime.getRuntime().exec("command", options);
这也不起作用,因为未指定 m
参数。
原文由 Alex 发布,翻译遵循 CC BY-SA 4.0 许可协议
看看这是否有效(抱歉现在无法测试)