执行通过ant获取输入的shell脚本

时间:2013-06-24 06:55:12

标签: unix ant

我有input.sh shell脚本,要求用户输入,它工作正常!!现在我想通过ant调用input.sh,我能够做到这一点,但我无法将输入传递给shell脚本。我错过了什么?下面是带有执行结果的build.xml和input.sh的剪切。

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"

结果:

[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>

结果:

[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

非常感谢任何有关此事的帮助!!

1 个答案:

答案 0 :(得分:0)

您可能想要传递$Orgname中的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>