如何用参数执行命令? [英] How to execute command with parameters?

查看:134
本文介绍了如何用参数执行命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用参数在Java中执行命令?

How to execute 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参数。

Does'n work also, because it doesn't specify the "m" parameter.

推荐答案

看看是否有效(抱歉现在无法测试)

See if this works (sorry can't test it right now)

Runtime.getRuntime().exec(new String[]{"php","/var/www/script.php", "-m", "2"});

这篇关于如何用参数执行命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆