2013-06-24 91 views
0

我有input.sh shell腳本,它要求用戶輸入,它工作正常!!現在我想通過ant調用input.sh,我能夠做到這一點,但我無法將輸入傳遞給shell腳本。我錯過了什麼?以下是針對build.xml和input.sh的執行結果。執行通過螞蟻輸入的shell腳本

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" 

結果:

[[email protected] 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> 

結果:

[[email protected] 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

見的http://stackoverflow.com/questions/4176305/ant-exec-task-how-can-i-read-input-from-console-stdin – devnull

+0

可能重複的[通過螞蟻執行外殼腳本](http://stackoverflow.com/questions/17268696/executing-shell-script-through-ant) –

回答

0

您可能想要通過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> 
+0

input: [exec]/bin/bash:echo'yak'| input.sh:沒有這樣的文件或目錄 [exec]結果:127 它不能識別該語句。當被刪除「echo'犛牛'...它正確選取文件,但當我說它給出了上述錯誤 – mahesh