I need to copy a file to my machine from a remote machine. Are there any ant targets to do that?

Recommended Answers

All 5 Replies

I read the documentation, but I couldn't find a way to do that. So can sombody mention how to do that?

Use the 'copy' task

<project name="blank" default="copy_file">
   
    <property name="srcfile" value="\\remote_mc_name\srcdir\file.txt"/>
    <property name="destpath" value="C:\destdir"/>

    <target name="copy_file" >
      <copy
        file="${srcfile}"
        todir="${destpath}"/>
    </target>

</project>

you can use the IP address instead of the remote_mc_name for source file path

<get> is also available, depending on the specifics of what you are trying to get remotely.

I needed to copy .log file. According to above code I did that. But for copying, that file or folder containing that file must be shared. It is a limitation, but I think that is only way.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.