coolgokul
coolgokul

Reputation: 357

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.

Upvotes: 2

Views: 6491

Answers (2)

martin clayton
martin clayton

Reputation: 78105

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.

Upvotes: 6

Igor Chubin
Igor Chubin

Reputation: 64563

value="./setup"

without . at the beginning.

Upvotes: 0

Related Questions