我有input.sh shell脚本,它要求用户输入,它工作得很好!!。现在我想通过ant调用input.sh,我可以这样做,但无法将输入传递给shell脚本。我错过了什么?下面是build.xml和input.sh的截图和执行结果。
输入.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
在这件事上的任何帮助都将不胜感激!!
您可能需要在build.xml
中传递$Orgname
。
<project name="Sample" default="automate">
<target name="automate">
<exec executable="/bin/bash">
<arg value="echo 'yak' | /root/test/Work/input.sh"/>
</exec>
</target>
</project>