ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Barlock <barl...@us.ibm.com>
Subject Re: Exec Task Problem on Linux
Date Tue, 14 Apr 2015 19:21:12 GMT
Thank you, Steve.  If I make the executable="/bin/sh" and uncomment the 
protoc command, I get:

parsing buildfile 
jar:file:/usr/apache-ant-1.9.4/lib/ant.jar!/org/apache/tools/ant/antlib.xml 
with URI = 
jar:file:/usr/apache-ant-1.9.4/lib/ant.jar!/org/apache/tools/ant/antlib.xml 
from a zip file
    [mkdir] Skipping /root/CCM/srcProtobufJava because it already exists.
    [chmod] Executing 'chmod' with arguments:
    [chmod] '755'
    [chmod] '/root/protoc/bin/protoc'
    [chmod]
    [chmod] The ' characters around the executable and arguments are
    [chmod] not part of the command.
    [chmod] Applied chmod to 1 file and 0 directories.
     [exec] Current OS is Linux
     [exec] Setting environment variable: LD_LIBRARY_PATH=/root/protoc/lib
     [exec] Executing '/bin/sh' with arguments:
     [exec] '/root/protoc/bin/protoc'
     [exec] '--java_out=/root/CCM/srcProtobufJava'
     [exec] '--proto_path=/root/CCM/src/protobuf/asf'
     [exec] '/root/CCM/src/protobuf/asf/*.proto'
     [exec]
     [exec] The ' characters around the executable and arguments are
     [exec] not part of the command.
     [exec] /root/protoc/bin/protoc: /root/protoc/bin/protoc: cannot 
execute binary file
     [exec] Result: 126

Thoughts?

Chris

From:   Steve Schlaifer <steve@jetcafe.org>
To:     Ant Users List <user@ant.apache.org>
Date:   04/14/2015 03:15 PM
Subject:        Re: Exec Task Problem on Linux



On Tue, Apr 14, 2015 at 02:35:03PM -0400, Chris Barlock wrote:
> I have the following Ant script:
> 
> <project name="build" default="all" basedir=".">
>     <target name="all">
>         <property name="srcDir" value="/root/CCM/src"/>
>         <property name="srcProtobufJavaDir" 
> value="/root/CCM/srcProtobufJava"/>
>         <property name="prereqToolsDir" value="/root/protoc"/>
>         <mkdir dir="${srcProtobufJavaDir}"/>
>         <chmod file="${prereqToolsDir}/bin/protoc" perm="755"/>
>         <exec executable="${prereqToolsDir}/bin/protoc">
>             <!-- <arg value="${prereqToolsDir}/bin/protoc"/> -->
>             <arg value="--java_out=${srcProtobufJavaDir}"/>
>             <arg value="--proto_path=${srcDir}/protobuf/asf"/>
>             <arg value="${srcDir}/protobuf/asf/*.proto"/>
>             <env key="LD_LIBRARY_PATH" value="${prereqToolsDir}/lib"/>
>        </exec>
>     </target>
> </project>
> 
> When I run this, I get:
> 
> [root@nc9042036240 ~]# /usr/apache-ant-1.9.4/bin/ant -v -f build.xml
> Apache Ant(TM) version 1.9.4 compiled on April 29 2014
> Buildfile: /root/build.xml
> Detected Java version: 1.7 in: 
> /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64/jre
> Detected OS: Linux
> parsing buildfile /root/build.xml with URI = file:/root/build.xml
> Project base dir set to: /root
> Build sequence for target(s) `all' is [all]
> Complete build sequence is [all, ]
> 
> all:
> parsing buildfile 
> 
jar:file:/usr/apache-ant-1.9.4/lib/ant.jar!/org/apache/tools/ant/antlib.xml 

> with URI = 
> 
jar:file:/usr/apache-ant-1.9.4/lib/ant.jar!/org/apache/tools/ant/antlib.xml 

> from a zip file
>     [mkdir] Skipping /root/CCM/srcProtobufJava because it already 
exists.
>     [chmod] Executing 'chmod' with arguments:
>     [chmod] '755'
>     [chmod] '/root/protoc/bin/protoc'
>     [chmod]
>     [chmod] The ' characters around the executable and arguments are
>     [chmod] not part of the command.
>     [chmod] Applied chmod to 1 file and 0 directories.
>      [exec] Current OS is Linux
>      [exec] Setting environment variable: 
LD_LIBRARY_PATH=/root/protoc/lib
>      [exec] Executing '/root/protoc/bin/protoc' with arguments:
>      [exec] '--java_out=/root/CCM/srcProtobufJava'
>      [exec] '--proto_path=/root/CCM/src/protobuf/asf'
>      [exec] '/root/CCM/src/protobuf/asf/*.proto'
>      [exec]
>      [exec] The ' characters around the executable and arguments are
>      [exec] not part of the command.
>      [exec] /root/CCM/src/protobuf/asf/*.proto: No such file or 
directory
>      [exec] Result: 1
> 
> Running the equivalent command manually works just fine:
> /root/CCM/src/protobuf/asf/*.proto
> /root/protoc/bin/protoc --java_out=/root/CCM/srcProtobufJava/ 
> --proto_path=/root/CCM/src/protobuf/asf 
/root/CCM/src/protobuf/asf/*.proto
> 
> (It silently compiles a set of Google Protobuf files.)  I originally set 

> the executable to "/bin/sh" and the protoc command was the first arg, 
> which you can see commented out above.  With this arrangement, the exec 
> task failed saying "cannot execute binary file" for protoc.  Where have 
I 
> gone wrong here? 

Wild cards like /root/CCM/src/protobuf/asf/*.proto are expanded by the
shell in unix type o/s's.  When you took out the /bin/sh you no longer
get this expanded.  It works when you run it from the command line
because you are giving the command to the shell and it expands the
wildcard for you.

-- 

                --Steve

"The world is a dangerous place to live; not because of the people who are
evil, but because of the people who don't do anything about it. "
                --Albert Einstein.

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



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message