如何在 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
参数。
最佳答案
看看这是否有效(抱歉,现在无法测试)
Runtime.getRuntime().exec(new String[]{"php","/var/www/script.php", "-m", "2"});
关于java - 如何执行带参数的命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7134486/