0

I have input.sh shell script which asks for user input,it works fine!!. Now i want to call input.sh through ant,i am able to do that but i'm not able to pass the input to the shell script. I have missed anything? Below is the snipped for build.xml and input.sh with execution result.

input.sh

#!/bin/bash

echo "enter the Organization name"
read Orgname
echo "Orgname is : $Orgname"
sed "s/000/$Orgname/g" Final.sql >> ExecuteID.sql
echo "Organization name has been replaced with $Orgname"

Result:

[root@krog2-rhel5-64 Work]# ./input.sh
enter the Organization name
**yak
Orgname is : yak
Organization name has been replaced with yak**

build.xml

<project name="Sample" default="automate">
<target name="automate">
<exec executable="/bin/bash">
<arg value="/root/test/Work/input.sh"/>
<arg value="/root/test/Work"/>
</exec>
</project>

Result:

[root@krog2-rhel5-64 Work]# ant
Buildfile: /root/test/Work/build.xml

automate:
     [exec] enter the Organization name
     [exec] **Orgname is :
     [exec] Organization name has been replaced with**

BUILD SUCCESSFUL
Total time: 0 seconds

Any help in this matter will be greatly appreciated!!

Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
mahesh
  • 274
  • 2
  • 4
  • 20
  • See http://stackoverflow.com/questions/4176305/ant-exec-task-how-can-i-read-input-from-console-stdin – devnull Jun 24 '13 at 07:39
  • possible duplicate of [Executing Shell Script through ant](http://stackoverflow.com/questions/17268696/executing-shell-script-through-ant) – Gilbert Le Blanc Jun 24 '13 at 18:37

1 Answers1

0

You may want to pass the $Orgname in the build.xml.

<project name="Sample" default="automate">   
  <target name="automate">
    <exec executable="/bin/bash">
      <arg value="echo 'yak' | /root/test/Work/input.sh"/>
    </exec>   
  </target> 
</project>
Jiri Kremser
  • 12,471
  • 7
  • 45
  • 72
  • input: [exec] /bin/bash: echo 'yak' | input.sh: No such file or directory [exec] Result: 127 it is not identifying that statement. when is removed "echo 'yak'...its picking the file correctly but when i say it gives above mentioned error – mahesh Jun 25 '13 at 05:30