如何分割字符串,并以Ant脚本使用内循环? [英] How to split a string and use it inside a for loop in ant script?

查看:533
本文介绍了如何分割字符串,并以Ant脚本使用内循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有机器的IPS在蚂蚁财产清单。

I am having a list of machine ips in a ant property.

<property name="machines" ip="10.10.10.1;10.10.10.2;10.10.10.3"/>

我有一个文件复制到所有的机器(所有的计算机是Windows计算机)。所以我想拆分此字符串,并使用它里面一个for循环。这里面我forloop将执行copy命令。

I have to copy one file to all the machines(all the machines are windows machines). So I want to split this string and to use it inside a for loop. Inside that forloop i will execute the copy command.

<exec executable="cmd.exe">
<pre>
</pre>
<arg line="/C COPY /Y sample.txt \\${machine_ip}\Shared_folder\sample.txt"/>
<pre>
</pre>
</exec>

现在如何拆分和内部使用它的循环?

Now how to split and use it inside for loop?

推荐答案

最简单的方法是用蚂蚁的contrib功能

Easiest way is to use the ant-contrib features


<for list="10.10.10.1;10.10.10.2" delimiter=";" param = "val">
<sequential>
<echo message = "val = @{val}"/>
</sequential>
</for>

这篇关于如何分割字符串,并以Ant脚本使用内循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆