如何用参数执行命令?
如何使用参数在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”参数。
看看这个工程(对不起,现在不能testing)
 Runtime.getRuntime().exec(new String[]{"php","/var/www/script.php", "-m", "2"}); 
 使用ProcessBuilder而不是Runtime#exec() 。 
 ProcessBuilder pb = new ProcessBuilder("php", "/var/www/script.php", "-m 2"); Process p = pb.start(); 
以下应该工作正常。
 Process p = Runtime.getRuntime().exec("php /var/www/script.php -m 2"); 
 在同一选项中使用-m和后面的一样。 如在-m 2