The propose of this tutorial is to retrieve the current logged username, computer name and operation system name in Ant, we echo these values in below example. Computer name and OS name are actually Ant build-in properties.
This is an example to get values in Ant.
Build.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- Here is how you can access How to get username, computer name and OS Name in ANT. --> <project basedir="." default="echosysteminfos" name="Echo username, computer name and OS Name"> <target name="echosysteminfos"> <property environment="my_env" /> <echo> Username is ${my_env.COMPUTERNAME} Computer name is ${user.name} OS Name is ${os.name} </echo> </target> </project>
This was the output after executing this ant script.
C:\temp>ant
Buildfile: build.xmlechosysteminfos:
[echo]
[echo] Username is asjava-PC
[echo] Computer name is asjava
[echo] OS Name is Windows NT (unknown)
[echo]BUILD SUCCESSFUL
Total time: 0 seconds
Buildfile: build.xmlechosysteminfos:
[echo]
[echo] Username is asjava-PC
[echo] Computer name is asjava
[echo] OS Name is Windows NT (unknown)
[echo]BUILD SUCCESSFUL
Total time: 0 seconds