>I wrote the following simple code to map a NT drive to some path:
>
>       <target name="map_drive" depends="" description="-->
description">
>               <exec executable="cmd.exe">
>                       <arg value="NET USE N: \\cm-web01"/>
>               </exec>
>       </target>
>
>And once I execute it, I get the following errors:
>
>       "The ' characters around the executable and arguments are not
part of the command."


Where is the problem? This is not an error message, it is just for
information.
Your log:

Apache Ant version 1.7.0 compiled on December 13 2006
Buildfile: C:\Documents and Settings\yonae\workspace\web_build\test.xml
parsing buildfile C:\Documents and
Settings\yonae\workspace\web_build\test.xml with URI =
file:/C:/Documents%20and%20Settings/yonae/workspace/web_build/test.xml
Project base dir set to: C:\Documents and
Settings\yonae\workspace\web_build
Build sequence for target(s) `map_drive' is [map_drive]
Complete build sequence is [map_drive, full_build, ]
map_drive:
[antlib:org.apache.tools.ant] Could not load definitions from resource
org/apache/tools/ant/antlib.xml. It could not be found.
     [exec] Current OS is Windows XP
     [exec] Executing 'cmd.exe' with arguments:
     [exec] 'NET USE N: \\cm-web01'
     [exec] 
     [exec] The ' characters around the executable and arguments are
     [exec] not part of the command.
     [exec] Microsoft Windows XP [Version 5.1.2600]
     [exec] (C) Copyright 1985-2001 Microsoft Corp.
     [exec] C:\Documents and Settings\yonae\workspace\web_build>
BUILD SUCCESSFUL
Total time: 250 milliseconds



The build finished successful, no error messages from/inside cmd.exe ...


I tried your code and there are two problems:
1. use <arg line> instead of <arg value> because spaces must not be
masked
2. use a leading "/C" because cmd.exe needs that ...


<project>
    <property name="drive" value="B:"/>
    <property name="unc"  value="\\computer\share"/>
    
    <exec executable="cmd.exe">
        <arg line="/C NET USE ${drive} ${unc}"/>
    </exec>
</project>


Tried out with 
  $net use
  $ant
  $net use
ant I could see that the drive was not connected before and was
connected after the Ant run.



If you want to encapsulate this command you could use <macrodef> for
that.

<project>
    <macrodef name="mapdrive">
        <attribute name="drive"/>
        <attribute name="unc"/>
        <sequential>
                        <exec executable="cmd.exe" taskname="mapdrive">
                <arg line="/C NET USE @{drive} @{unc}"/>
                        </exec>
        </sequential>
    </macrodef>

    <macrodef name="unmapdrive">
        <attribute name="drive"/>
        <sequential>
                        <exec executable="cmd.exe"
taskname="unmapdrive">
                <arg line="/C NET USE @{drive} /D"/>
                        </exec>
        </sequential>
    </macrodef>

    <target name="map">
        <mapdrive drive="B:" unc="\\L011benutzer\f007777"/>
    </target>
    <target name="unmap">
        <unmapdrive drive="B:"/>
    </target>
</project>



Next step would be a "windows AntLib" .... ;)



Jan





Jan

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to