简体   繁体   中英

How do I troubleshoot an ANT “exec” command line error message?

Using an Ant script, I am trying to build the bar file to deploy in IIB Server. But I am facing an error like:

BIP0960E Incorrect "-a", "-l", "-p", or "-o" argument supplied to mqsicreatebar

Please do let me know how to solve this error.

Thank You.

I am using the following ant script :

<?xml version="1.0" encoding="UTF-8"?>
<project name="Test" default="Create_bar" basedir=".">
    <property file="ucd.properties"></property>
     <taskdef resource="net/sf/antcontrib/antlib.xml">
          <classpath>
              <pathelement location="C:\apache-ant-1.9.6\lib\antcontrib.jar"/>
          </classpath>
     </taskdef>  

     <!-- Making Windows command environment  -->
     <target name="mqsiprofile.cmd">
     <exec executable="${broker.mqsi.path}\mqsiprofile.cmd" />
     </target>
//  <!-- Creating a bar file -->
        <target name="Create_bar">
            <for list="${project_name}" delimiter="," param="pName">
                <sequential>
                <echo message="@{pName}"/>
                <exec executable="${toolkit.home}\mqsicreatebar.exe" spawn="false" vmlauncher="false" failonerror="true">
                //  <!-- project's workspace-->
                    <arg value="-data" />
                    <arg value="${workspaces.dir}" />
                    <!--barfile generated path-->
                    <arg value="-b" />
                    <arg value="${bar.loc}\@{pName}.msgflow.generated.bar" />
                    <!--project Name-->
                    <arg value="-p" />
                    <arg value="@{pName}" />
                    <!--Message flows for its corresponding projects which has given in cvsCheckout.properties-->
                    <arg value="-o" />
                    <arg line="@{bar.loc}\${@{pName}.flow_name}" />
                    <arg line="@{bar.loc}\IAM_Demo_Compute.esql" />
                <arg value="-deployAsSource" />
                </exec> 
                </sequential>
            </for>
        </target>

    </project>

I placed all the necessary components to build the bar file.

The BIP0960 error message above indicates you have passed the incorrect parameters to the executable you are running in your script. You need to troubleshoot the parameter string you are passing to your executable.

It can be hard to debug ANT exec statements in the way that you have structured them.

A good technique for debugging ANT scripts is to create a single property for the command line parameter string, and then echo those parameters to the console to confirm their construction. Use this parameter string output to review, test, modify and re-run the command and its parameters, until they work.

To do this, refactor your exec statement so it references the single parameter string, called ${myParams}:

<!-- create the command parameters -->
<property name="myParams" value="-data ${workspaces.dir} -b ${bar.loc}\@{pName}.msgflow.generated.bar -p @{pName -o @{bar.loc}\${@{pName}.flow_name} @{bar.loc}\IAM_Demo_Compute.esql -deployAsSource" />       
<!-- echo myParams -->
<echo message="myParams: ${myParams}" />
<!-- pass myParams to the executable -->
<exec executable="${toolkit.home}\mqsicreatebar.exe" spawn="false" vmlauncher="false" failonerror="true">
  <arg line="${myParams}" />
</exec> 

The echo statement will show you the property variables expanded. Copy and paste this to the command line, and try again. When you have the right parameters, copy and paste that back into your script, replacing static values with the correct variables.

Likewise it is easier to manage changes to the command line as one property, instead of multiple arg values.

Use this construction, and you can easily troubleshot any exec command problems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM