当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Ant: No such file or directory

问题描述:

I need to write ant script to execute one file in linux but prior to execution of file i need to execute setup file.

in putty i used to something like ". ./setup" and then "./executeme"

In same way i have written ant script as

 <exec dir="${dir}" executable="/bin/sh">

<arg value=". ./setup"/>

<arg value="./executeme"/>

</exec>

But it gives error as "/bin/sh: . ./setup: No such file or directory".

Also can someone explain me the difference between execution of "./setup" and ". ./setup "??

thanks in advance.

网友答案:

You can run the command sequence you use in an interactive session by creating a single-line script, and passing it to sh using -c like this:

<exec dir="${dir}" executable="/bin/sh">
    <arg value="-c"/>
    <arg value=". ./setup; ./executeme"/>
</exec>

You need to pass the two commands as one arg, otherwise they are treated differently: the first one becomes the 'script' and the next becomes the first argument for that script. Or, if you like, the above is equivalent to running

sh -c ". ./setup; ./executeme"

whereas with separate arg elements, you are running

sh -c ". ./setup" ./executeme

That probably won't appear to fail, unless setup does something its argument list, but it won't run executeme.

网友答案:
value="./setup"

without . at the beginning.

分享给朋友:
您可能感兴趣的文章:
随机阅读: