how to exec command in new prompt using ant

此生再无相见时 提交于 2019-12-11 07:42:31

问题


I am trying to run a command in ant to start the selenium server but it opens up in the same command prompt, is there anyway i can open it up in a new prompt?

<project>
<target name="startGRID">
    <exec dir="." executable="cmd">
        <arg value="/c"/>
        <arg value="java -jar selenium-server-standalone-2.43.1.jar -role hub"/>
    </exec>
</target>
</project>

回答1:


To see a separate command prompt in which your server is run, use the dos start command, which does exactly that:

<exec dir="." executable="cmd">
  <arg value="/c"/>
  <arg value="start"/>
  <arg value="java -jar selenium-server-standalone-2.43.1.jar -role hub"/>
</exec>

The only issue I find with that is that, when the server is terminated, the new command prompt window will remain open. This can be worked around by wrapping the java command in a batch script, let's call it start-selenium.bat, with an exit statement at the end:

java -jar selenium-server-standalone-2.43.1.jar -role hub
exit

then the Ant task becomes:

<exec dir="." executable="cmd">
  <arg value="/c"/>
  <arg value="start"/>
  <arg value="start-selenium.bat"/>
</exec>


来源:https://stackoverflow.com/questions/26166912/how-to-exec-command-in-new-prompt-using-ant

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!