我有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
非常感谢任何有关此事的帮助!!
答案 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>