You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Srinivasan Ranganathan <sr...@gmail.com> on 2004/11/01 04:11:34 UTC

Running DB2 scripts from a shell

Hi

I have a DB2 script that creates a database. I'd like my build to drop
and recreate the db everytime. To run the DB2 script, I need to setup
the environment for it beforehand. I have this working well. The issue
is that to run the DB2 script, I need to run a batch file which opens
a new shell. I have a target like so...

    <target name="create-db" depends="init">
        <!-- Drops the existing db and creates a new one without any tables -->
        <exec executable="${db2.home}/bin/${db2.command}">
            <arg value="${db2.commandline.arg1}"/>
            <arg value="${db2.commandline.arg2}"/>
            <arg value="${db2.command.options}"/>
            <arg value="${db.create.script}"/>
        </exec>
    </target>

At this point, I want to create some tables (which I do with the sql
task). Since the create script runs in a separate shell, the target
returns immediately even if the db is still being created. So
subsequent tasks fail.

I want the create-db target to complete only after the db has been
created. I accomplished this by sleeping for a few mintues. But this
isn't a good solution. I looked at the waitfor task. I could use it
with the istrue condition and set a property to true if the connection
succeeds. The problem with this is, how do I set the property? I could
use the sql task to do a simple connection. But from the docs, I don't
failureproperty for the sql task.

Thanks in advance.
Srini

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org