我正努力达到以下要求
我在ant构建文件中编写一个逻辑来比较我的系统ip地址的值,并根据它执行scp任务,我在shell脚本中获取本地IP地址并将其作为ANT参数的一部分传递< / p>
Shell脚本内容
导出IP_ADDR = ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'
$ ant_home / ant -listener $ listener -Dlocal.ipaddress = $ {IP_ADDR} -buildfile BuildHome / build.xml
现在,用户调用此shell脚本以及属性文件。
属性文件值
<user-request>
<prop-value name = "TESTApp">
<action>install</action>
<target-location>/apps/properties/messagadapter</target-location>
<members-info>
<ip-address>10.xx.xx.xx</ip-address>
<ip-address>10.yy.yy.yy</ip-address>
</members-info>
<file-name>test12.xml</file-name>
<file-name>test23.xml</file-name>
</prop-value>
</user-request>
我已经编写了所有必要的XSLT转换,并且能够将用户xml转换为如下所示
<?xml version="1.0" encoding="UTF-8"?><project name="test" default="request" basedir=".">
<target name="process-request">
<ant antfile="build.xml" target="property" dir=".">
<property name="package.name" value="TESTApp"/>
<property name="target" value="install"/>
<property name="target.location" value="/tmp/properties/applications1"/>
<property name="file.list" value="test12.xml,test23.xml"/>
<property name="member.ipaddress" value="10.xx.xx.xx,10.yy.yy.yy"/>
</ant>
</target>
</project>
我的build.xml如下所示,我想检查ipaddress是否等于localipaddress然后执行必要的操作但由于某种原因它永远不会进入IF循环,虽然该值等于本地IP地址它总是跳过if条件并转到else,
<target name = "deploy" depends="defineAntContribTasks">
<echo message = "Copying Property files ${file.list} to ${target.location} "/>
<echo message = " The value of the local ipaddress us .... ${local.ipaddress} "/>
<echo message = " The value of the member ino ... ${member.ipaddress} "/>
<for list="${member.ipaddress}" param="ipaddress">
<sequential>
<if>
<equals arg1="@{ipaddress}" arg2="{local.ipaddress}"/>
<then>
<copy todir="${target.location}" overwrite="true">
<fileset dir="${input.prop}" includes = "${file.list}"/>
</copy>
</then>
<else>
<echo message = " Inside the else loop ... "/>
<echo message = " The value of the ip is ... @{ipaddress}"/>
<property name="remoteipaddress" value="@{ipaddress}" />
<scp keyfile="/home/fsadmin/.ssh/id_dsa" todir="fsadmin@${remoteipaddress}:${target.location}" passphrase="" trust="true">
<fileset dir="${input.prop}" includes="${file.list}"/>
</scp>
</else>
</if>
</sequential>
</for>
</target>
我不确定这是否失败,因为我们正在做一个字符串到int操作或其他一些原因,我不知道我错过了哪个条件可以请一些人指导我