这是我的代码:
String cmd = "bash -c \"php /Users/phyrrus9/Projects/java-web/test.php | say\"";
System.out.println("Executing: " + cmd);
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(cmd);
然而,它永远不会被执行。我可以从 shell 运行该命令,它工作正常。这是test.php的内容
<?php
echo hello;
?>