如何执行带参数的命令? [英] How to execute command with parameters?
本文介绍了如何执行带参数的命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何在带有参数的 Java 中执行命令?
How am I to execute a command in Java with parameters?
我试过了
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
参数.
This doesn't work as well, because the m
parameter is not specified.
推荐答案
看看这个是否有效(抱歉现在不能测试)
See if this works (sorry can't test it right now)
Runtime.getRuntime().exec(new String[]{"php","/var/www/script.php", "-m", "2"});
这篇关于如何执行带参数的命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文