Grokbase Groups Ant user May 2005
FAQ
Hi All

I am facing an issue when I am trying to execute Ant Script in Suse Linux
Environment. I am using Ant Version 1.6.1. I am using exec Tag in
Build.xml to make connection to DB2 Database and then using Exec Tag again
to execute a SQL File

<exec executable="db2" output="db2-nagano.txt" append="true">
<arg line="-v CONNECT TO dummy USER db2admin USING db2pass" />
</exec>
<exec executable="db2" output="db2-nagano.txt" append="true">
<arg line="-f getNaganoInfo.sql" />
</exec>


In this case I would like that both Exec Commands should execute in same
Shell Environment so that Connection made by First Tag can be used by Tag
2

However I guess Ant is executing both the Command in different shell
environment and therefore connection made is not passed to next command
while executing sql file. Hence I am getting Error for "No Connection made
to database".

This Script seems to be working perfectly fine in Windows Environment.
Also If I manually type my Command on prompt at Linux shell then also I
get correct result. Only when I try to do this task using Ant Script I am
getting this Error which suggest that exec Command is not executing in
same shell in Linux. Can some one please suggest me workaround for this
issue as this has become a High Prioroty Issue.



Thanks and Regards
------------------------------------------------------------------------------------------------------------------
Kapil Bajaj
India Software Labs
IBM Software Group.
Email : kapilbajaj@in.ibm.com

Search Discussions

  • Alexey N. Solofnenko at May 21, 2005 at 4:51 pm
    If it works on a command line, write a batch script and execute it as
    "cmd /c batch.bat".

    - Alexey.

    Kapil Bajaj wrote:
    Hi All

    I am facing an issue when I am trying to execute Ant Script in Suse
    Linux
    Environment. I am using Ant Version 1.6.1. I am using exec Tag in
    Build.xml to make connection to DB2 Database and then using Exec Tag
    again
    to execute a SQL File

    <exec executable="db2" output="db2-nagano.txt" append="true">
    <arg line="-v CONNECT TO dummy USER db2admin USING db2pass"
    />
    </exec>
    <exec executable="db2" output="db2-nagano.txt" append="true">
    <arg line="-f getNaganoInfo.sql" />
    </exec>


    In this case I would like that both Exec Commands should execute in same

    Shell Environment so that Connection made by First Tag can be used by
    Tag
    2

    However I guess Ant is executing both the Command in different shell
    environment and therefore connection made is not passed to next command
    while executing sql file. Hence I am getting Error for "No Connection
    made
    to database".

    This Script seems to be working perfectly fine in Windows Environment.
    Also If I manually type my Command on prompt at Linux shell then also I
    get correct result. Only when I try to do this task using Ant Script I
    am
    getting this Error which suggest that exec Command is not executing in
    same shell in Linux. Can some one please suggest me workaround for this
    issue as this has become a High Prioroty Issue.



    Thanks and Regards
    ------------------------------------------------------------------------
    ------------------------------------------
    Kapil Bajaj
    India Software Labs
    IBM Software Group.
    Email : kapilbajaj@in.ibm.com

    --
    ------------------------------------------------------------------------
    / Alexey N. Solofnenko
    home: http://trelony.cjb.net/
    /

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Paul Elschot at May 21, 2005 at 7:31 pm

    On Saturday 21 May 2005 18:50, Alexey N. Solofnenko wrote:
    If it works on a command line, write a batch script and execute it as
    "cmd /c batch.bat".
    With an os="windows" to the exec.
    For unix/linux on can use "bash -c scriptname", or inline the script
    from within the build file using a (bracketed) list of commands
    separated by semicolons after the bash -c .

    Regards,
    Paul Elschot

    - Alexey.

    Kapil Bajaj wrote:
    Hi All

    I am facing an issue when I am trying to execute Ant Script in Suse
    Linux
    Environment. I am using Ant Version 1.6.1. I am using exec Tag in
    Build.xml to make connection to DB2 Database and then using Exec Tag
    again
    to execute a SQL File

    <exec executable="db2" output="db2-nagano.txt" append="true">
    <arg line="-v CONNECT TO dummy USER db2admin USING db2pass"
    />
    </exec>
    <exec executable="db2" output="db2-nagano.txt" append="true">
    <arg line="-f getNaganoInfo.sql" />
    </exec>


    In this case I would like that both Exec Commands should execute in same

    Shell Environment so that Connection made by First Tag can be used by
    Tag
    2

    However I guess Ant is executing both the Command in different shell
    environment and therefore connection made is not passed to next command
    while executing sql file. Hence I am getting Error for "No Connection
    made
    to database".

    This Script seems to be working perfectly fine in Windows Environment.
    Also If I manually type my Command on prompt at Linux shell then also I
    get correct result. Only when I try to do this task using Ant Script I
    am
    getting this Error which suggest that exec Command is not executing in
    same shell in Linux. Can some one please suggest me workaround for this
    issue as this has become a High Prioroty Issue.



    Thanks and Regards
    ------------------------------------------------------------------------
    ------------------------------------------
    Kapil Bajaj
    India Software Labs
    IBM Software Group.
    Email : kapilbajaj@in.ibm.com

    --
    ------------------------------------------------------------------------
    / Alexey N. Solofnenko
    home: http://trelony.cjb.net/
    /

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


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Sten Rosendahl at May 21, 2005 at 7:35 pm
    Why not try this:

    <exec executable="bash" output="db2-nagano.txt" append="true">
    <arg line="-c 'db2 -v CONNECT TO dummy USER db2admin USING db2pass && db2 -f getNaganoInfo.sql'">
    </exec>
    Kapil Bajaj wrote:
    Hi All

    I am facing an issue when I am trying to execute Ant Script in Suse
    Linux
    Environment. I am using Ant Version 1.6.1. I am using exec Tag in
    Build.xml to make connection to DB2 Database and then using Exec Tag
    again
    to execute a SQL File

    <exec executable="db2" output="db2-nagano.txt" append="true">
    <arg line="-v CONNECT TO dummy USER db2admin USING db2pass"
    />
    </exec>
    <exec executable="db2" output="db2-nagano.txt" append="true">
    <arg line="-f getNaganoInfo.sql" />
    </exec>


    In this case I would like that both Exec Commands should execute in same

    Shell Environment so that Connection made by First Tag can be used by
    Tag
    2

    However I guess Ant is executing both the Command in different shell
    environment and therefore connection made is not passed to next command
    while executing sql file. Hence I am getting Error for "No Connection
    made
    to database".

    This Script seems to be working perfectly fine in Windows Environment.
    Also If I manually type my Command on prompt at Linux shell then also I
    get correct result. Only when I try to do this task using Ant Script I
    am
    getting this Error which suggest that exec Command is not executing in
    same shell in Linux. Can some one please suggest me workaround for this
    issue as this has become a High Prioroty Issue.
  • Kapil Bajaj at May 24, 2005 at 7:29 am
    Hello Sten

    Thanks a lot for Intresting solution for this issue and it works. You have
    saved lot of Effort for me. I just made a small change in solution
    suggested

    Correct Syntax would be
    <exec executable="bash" output="db2-nagano.txt" append="true">
    <arg line="-c 'db2 -v CONNECT TO dummy USER db2admin USING
    db2pass &amp;&amp; db2 -f getNaganoInfo.sql'">
    </exec>
    and this worked otherwise we get Error if we use && as it start assuming
    it as some entity



    <sten.rosendahl@sungard.com>
    05/22/2005 12:31 AM
    Please respond to
    "Ant Users List"


    To
    <user@ant.apache.org>
    cc

    Subject
    RE: Urgent Help Required:<Exec> Issue with Suse Linux






    Why not try this:

    <exec executable="bash" output="db2-nagano.txt" append="true">
    <arg line="-c 'db2 -v CONNECT TO dummy USER db2admin USING
    db2pass && db2 -f getNaganoInfo.sql'">
    </exec>
    Kapil Bajaj wrote:
    Hi All

    I am facing an issue when I am trying to execute Ant Script in Suse
    Linux
    Environment. I am using Ant Version 1.6.1. I am using exec Tag in
    Build.xml to make connection to DB2 Database and then using Exec Tag
    again
    to execute a SQL File

    <exec executable="db2" output="db2-nagano.txt" append="true">
    <arg line="-v CONNECT TO dummy USER db2admin USING db2pass"
    />
    </exec>
    <exec executable="db2" output="db2-nagano.txt" append="true">
    <arg line="-f getNaganoInfo.sql" />
    </exec>


    In this case I would like that both Exec Commands should execute in same

    Shell Environment so that Connection made by First Tag can be used by
    Tag
    2

    However I guess Ant is executing both the Command in different shell
    environment and therefore connection made is not passed to next command
    while executing sql file. Hence I am getting Error for "No Connection
    made
    to database".

    This Script seems to be working perfectly fine in Windows Environment.
    Also If I manually type my Command on prompt at Linux shell then also I
    get correct result. Only when I try to do this task using Ant Script I
    am
    getting this Error which suggest that exec Command is not executing in
    same shell in Linux. Can some one please suggest me workaround for this
    issue as this has become a High Prioroty Issue.
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriesant
postedMay 21, '05 at 9:23a
activeMay 24, '05 at 7:29a
posts5
users4
websiteant.apache.org

People

Translate

site design / logo © 2022 Grokbase