Reputation: 716
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
Upvotes: 0
Views: 1142
Reputation: 716
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.
Upvotes: 0