Date: 2004-03-08T09:01:52 Editor: StefanBodewig <[EMAIL PROTECTED]> Wiki: Ant Wiki Page: AntOddities URL: http://wiki.apache.org/ant/AntOddities
merge from old wiki Change Log: ------------------------------------------------------------------------------ @@ -227,3 +227,80 @@ I got very nice results when starting with -quiet mode. ''Jan Matèrne'' + +== Windows XP exec task : use os="Windows XP" instead of "os="Windows NT" despite docs == + +using ant 1.6.1 with j2sdk1.4.2 + +Doc incorrectly says you should use os="Windows NT" for the exec task to lauch a batch file + +If you try to launch a batch file with 'exec' task, +you should try to use instead : +{{{ + <exec dir="bat" executable="cmd" os="Windows XP" failonerror="true"> + <arg line="/c somebatch.bat"/> + </exec> +}}} + +If you encounter such a problem, try a verbose execution: + +ant - verbose build.xml + +this should give you these results: (I've just tailored an adapted build.xml) + +{{{ +XP_as_NT: + [echo] batch.bat creation with content : '/c dir ..\ >dirNT.txt' + [echo] exec executable='cmd' os='Windows NT' failonerror='true' + [exec] Current OS is Windows XP + [exec] This OS, Windows XP was not found in the specified list of valid OSes: Windows NT +[available] Unable to find dirNT.txt to set property Success.XP_as_NT +Property ${Success.XP_as_NT} has not been set + [echo] Success.XP_as_NT : ${Success.XP_as_NT} + +BUILD SUCCESSFUL +Total time: 3 seconds +}}} + +Compared to this one :{{{ +XP_as_XP: + [echo] Batch file creation with content : '/c dir ..\ >dirXP.txt' + [echo] exec executable='cmd' os='Windows XP' failonerror='true' + [exec] Current OS is Windows XP + [exec] Executing 'cmd' with arguments: + [exec] '/c' + [exec] 'batchXP.bat' + [exec] + [exec] The ' characters around the executable and arguments are + [exec] not part of the command. + + [exec] F:\trucking\ant\bat>dir ..\ 1>dirXP.txt + + +[available] Found: dirXP.txt in F:\trucking\ant\bat + [echo] Success.XP_as_XP : true + +BUILD SUCCESSFUL +Total time: 3 seconds +}}} + +Sadly enough, the env variable OS on Windows XP says : Windows_NT, and doesn't reflect +what you see on these verbose execution. + +The only simple way to determine os seems then with the windir env variable; +which happens to be <somedrive>\WINNT on windows NT and <somedrive>\Windows on windows XP + +You may test it that way:{{{ +<project name="YourProject"> + +<property environment ="env"/> + +<target name="init"> + <condition property="osIsXP"> + <equals arg1="${env.HOMEDRIVE}\WINDOWS" + arg2="${env.windir}"/> + </condition> +</target> +}}} + +''Marc Persuy'' --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]