How to run LDAP delete entry tool in linux using ANT task - linux

In linux, I am able to run ldapdelete like this
sudo ldapdelete -x -w 1234 -D "cn=Manager,o=project1" -r "o=project1"
now I want to do this using ANT task:
<target name="ldap-delete">
<exec executable="ldapdelete" failonerror="false">
<arg value="-x"/>
<arg value="-w"/>
<arg value="${ldap.password}"/>
<arg value="-D"/>
<arg value=""${ldap.rootdn}""/>
<arg value="-r"/>
<arg value=""${ldap.entry}""/>
</exec>
</target>
but it failed when running ANT:
[exec] ldap_bind: Invalid DN syntax (34)
[exec] additional info: invalid DN
[exec] Result: 1
what is wrong with my ANT task script?
Thanks
according to martin clayton's comment, I removed quotes around the -D and -r arg values like this:
<arg value="-D"/>
<arg value="${ldap.rootdn}"/>
<arg value="-r"/>
<arg value="${ldap.entry}"/>
and run ant with verbose mode, I got the following error:
[echo] ldapdelete...
[exec] Current OS is Linux
[exec] Executing 'ldapdelete' with arguments:
[exec] '-x'
[exec] '-w'
[exec] '1234'
[exec] '-D'
[exec] 'cn=Manager,o=project1'
[exec] '-r'
[exec] 'o=project1'
[exec]
[exec] The ' characters around the executable and arguments are
[exec] not part of the command.
[exec] ldap_search: No such object (32)
[exec] ldap_delete: No such object (32)
[exec] Result: 32

ended up with a solution myself:
<target name="ldap-delete">
<exec executable="ldapdelete" failonerror="false">
<arg line="-x -w ${ldap.password} -D "${ldap.rootdn}" -r "${ldap.entry}""/>
</exec>
</target>

Related

Java Run command line error in Apache Ant 1.9.9

I am using ant to compile and run a java program, the program is successfully compiled but on running the desired output.txt is not generating. Is something wrong with run command?
COMPILE: ant -buildfile build.xml all
RUN: ant -buildfile build.xml run -Darg0=train_all_txt.txt -Darg1=output.txt
Code in build.xml :
<target name="run" depends="jar">
<java jar="${BUILD}/jar/recommenderSystem.jar" fork="true">
<arg value="${arg0}"/>
<arg value="${arg1}"/>
<arg value="${arg2}"/>
<arg value="${arg3}"/>
<arg value="${arg4}"/>
</java>
</target>

Unable to run bash script with ant exec task

I am trying to execute a bash script from ant exec task.
<target name="test" unless="${is.windows}">
<chmod file="./abc.sh" perm="a+x"/>
<exec dir="./" spawn="false" executable="bash" newenvironment="false">
<arg line="abc.sh ${some-argument}" />
</exec>
</target>
The bash script has shebang #!/bin/bash.
When I run the target, it gives me following output on our Jenkins machines where production code is built. It works fine on my local CentOS machines. Most of the lines are empty. On line 19, it has { (opening curly brace) -
[exec] abc.sh: line 2:
[exec] : command not foundabc.sh: line 7:
[exec] : command not foundabc.sh: line 8:
[exec] : command not foundabc.sh: line 12:
[exec] : command not foundabc.sh: line 14:
[exec] : command not foundabc.sh: line 17:
[exec] : command not foundabc.sh: line 19: syntax error near unexpected token `{
[exec] 'abc.sh: line 19: `{
[exec] '
[exec] Result: 2
It turns out that dos line endings was the problem. Setting svn eol property to native fixed the issue. As on our Jenkins server, the code is checked out for every build, the bash scripts being edited on Windows created line endings incompatible with centOS.

Property "Value" is already defined. How resolve from ANT

I am using ANT build.xml to generate java proxy class. There i am getting below error.
"[wsimport] [ERROR] Property "Value" is already defined. Use <jaxb:property> to resolve this conflict."
How to perform external binding through ANT build.xml.
Use xjc ANT task
write a bindings (.xjb) to define the appropriate jaxb:property
add -b argument to xjc execution task in ANT.
<arg value="-b"/>
<arg value="bindings.xjb"/>

ant build script for behat error

I am trying to setup an ant build script for behat tests so I can run them from jenkins. When I run behat from the command line with bin/behat or ./bin/behat, the output works as expected. But when I use the following ant script
<project name="behat" basedir=".">
<exec dir="bin" executable="./behat">
</exec>
</project>
I get this error:
Buildfile: <mydir>/build.xml
[exec]
[exec]
[exec]
[exec] [RuntimeException]
[exec] Context class not found.
[exec] Maybe you have provided wrong or no `bootstrap` path in your behat.yml:
[exec] http://docs.behat.org/guides/7.config.html#paths
[exec]
[exec]
[exec]
[exec] behat [--init] [-f|--format="..."] [--out="..."] [--lang="..."] [--[no-]ansi] [--[no-]time] [--[no-]paths] [--[no-]snippets] [--[no-]snippets-paths] [--[no-]multiline] [--[no-]expand] [--story-syntax] [-d|--definitions="..."] [--name="..."] [--tags="..."] [--cache="..."] [--strict] [--dry-run] [--rerun="..."] [--append-snippets] [--append-to="..."] [features]
[exec]
[exec]
[exec] Result: 1
BUILD SUCCESSFUL
Total time: 0 seconds
You shouldn't be running behat from the bin directory. It won't find your behat.yml file.
You should either run it like this:
./bin/behat
or pass a path to the config file:
cd bin
./bin/behat --config ../behat.yml
I haven't tried the later. Your ant script might look something like:
<project name="behat" basedir=".">
<exec dir="${basedir}" executable="./bin/behat" />
</project>
I took ant out of the equation and just used jenkins to run the behat commands directly:
cd <mydir>
bin/behat
One thing I need to check is the build from jenkins returns failed, but it may be due to the behat tests are failing.

Openlaszlo migration issues

When i am trying to migrate the code from OL 3.3 to 4.9 i am getting this error. I have followed the steps mentioned here.
http://wiki.openlaszlo.org/Runtime_Differences
But still i am getting this error.
[exec] Exception in thread "main" java.lang.NullPointerException
[exec] at org.openlaszlo.compiler.ClassModel.sortKey(ClassModel.java:235)
[exec] at org.openlaszlo.compiler.ClassModel.compareTo(ClassModel.java:244)
[exec] at java.util.TreeMap.put(TreeMap.java:560)
[exec] at java.util.TreeSet.add(TreeSet.java:255)
[exec] at java.util.AbstractCollection.addAll(AbstractCollection.java:334)
[exec] at java.util.TreeSet.addAll(TreeSet.java:312)
[exec] at java.util.TreeSet.<init>(TreeSet.java:160)
[exec] at org.openlaszlo.compiler.ViewSchema.resolveClassModels(ViewSchema.java:362)
[exec] at org.openlaszlo.compiler.Compiler.updateRootSchema(Compiler.java:809)
[exec] at org.openlaszlo.compiler.Compiler.compile(Compiler.java:452)
[exec] at org.openlaszlo.compiler.Compiler.compile(Compiler.java:199)
[exec] at org.openlaszlo.compiler.Main.compile(Main.java:463)
[exec] at org.openlaszlo.compiler.Main.lzc(Main.java:402)
[exec] at org.openlaszlo.compiler.Main.main(Main.java:105)
Has anyone come across the same type. Please let me know what is the solution.
The problem existed even in the 5.0 version but later by removing the dependencies one by one, i found that one of the class's default placement value is a constraint when i remove the constraint and give the proper name. The error was resolved.

Resources