Here is what you need to do if you want to fetch below in/using ANT:
a. Logged user - built-in property
b. Machine OS name - built-in property
c. Environment properties - ANT provides a property task which has an attribute environment. Thus if you specify the task with environment="myenv" you will be able to access OS-specific environment variables via property names "myenv.PATH" or "myenv.TERM".
Below is a sample ant script.
Helpful? Please Comment.
Happy Learning!!
a. Logged user - built-in property
b. Machine OS name - built-in property
c. Environment properties - ANT provides a property task which has an attribute environment. Thus if you specify the task with environment="myenv" you will be able to access OS-specific environment variables via property names "myenv.PATH" or "myenv.TERM".
Below is a sample ant script.
<?xml version="1.0" encoding="UTF-8" standalone="no"?><project basedir="." default="systeminfo"> <target name="systeminfo"> <property environment="my_env" /> <echo> User is ${user.name} OS Name is ${os.name} ANT_HOME is set to ${my_env.ANT_HOME}
</echo> </target></project>Output:BuildFile: build.xml systeminfo[echo] [echo] User is nadimwarsi[echo] OS Name is Windows 10 Enterprise[echo] ANT_HOME is set to C:\Program Files\Java\jdk1.7[echo] BUILD SUCCESSFULTotal time: 0 secondsHelpful? Please Comment.
Happy Learning!!
No comments:
Post a Comment