如何拆分字符串并在 ant 脚本的 for 循环中使用它? [英] How to split a string and use it inside a for loop in ant script?

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

问题描述

我有一个 ant 属性中的机器 ip 列表.

我必须将一个文件复制到所有机器上(所有机器都是 windows 机器).所以我想拆分这个字符串并在 for 循环中使用它.在那个 forloop 中,我将执行复制命令.

<预>

<arg line="/C COPY/Y sample.txt \\${machine_ip}\Shared_folder\sample.txt"/><预>

</exec>

现在如何拆分并在for循环中使用?

解决方案

最简单的方法是使用 ant-contrib 功能

<前><for list="10.10.10.1;10.10.10.2" delimiter=";"参数 = "val"><顺序><echo message = "val = @{val}"/></顺序></for>

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"/>

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?

解决方案

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 脚本的 for 循环中使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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