蚂蚁机器名称属性 [英] ant machine name property

查看:110
本文介绍了蚂蚁机器名称属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让机器名作为ant属性,用于Linux和Windows操作系统。

Is there a way to get the machine name as ant property, for both Linux and Windows OS.

推荐答案

在Windows上的主机名是在环境变量计算机,在Linux环境变量为主机名。因为Ant属性是不可变的像下面应该工作:

On Windows the hostname is in the environment variable "COMPUTERNAME", on Linux the environment variable is "HOSTNAME". Because ant properties are immutable something like the following should work:

<property environment="env"/>
<property name="env.HOSTNAME" value="${env.COMPUTERNAME}"/>
<echo message="hostname = ${env.HOSTNAME}"/>

即。导入环境与ENV pfixed性质$ P $。然后设置env.HOSTNAME为env.COMPUTERNAME的值,除非env.HOSTNAME已经设置在这种情况下,第二行不会有任何影响。之后在需要的主机名使用env.HOSTNAME。

i.e. import the environment as properties prefixed with env. Then set env.HOSTNAME to be the value of env.COMPUTERNAME unless env.HOSTNAME is already set in which case the 2nd line will have no effect. After that use env.HOSTNAME where the hostname is required.

这篇关于蚂蚁机器名称属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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