tags:

views:

552

answers:

3

can any one help me

how to copy file from unix Windoes system to windows UNIX using ant?

Thanks in advance

EDIT

Let me explain in detail what I am looking for I want to copy file from windows to unix machine (correcting my previous question not from unix to windows) using ANT. I thought of using ftp task.

Before that as a check I tried to ftp unix sever from windows but it gave connection refused error(Do I need to provide my username and password,if that is the case what is the syntax).

But I am able to connect through putty which asks for my user name and password. Does putty uses a different protocol.

So if that is the case does ftp task works for me in ANT?. If not what task I need to use?

A: 

You have a couple of options.

If you have a windows shared drive mounted on your windows you can simply use the task.

<copy>

http://ant.apache.org/manual/CoreTasks/copy.html

If you don't you'll need to set up some service in the Windows side, probably FTP, if that's the case you'll need to use the task:

<ftp>

http://ant.apache.org/manual/OptionalTasks/ftp.html

EDIT

As per your comment, this is all you need:

http://ant.apache.org/manual/OptionalTasks/ftp.html

Take a look at your server ( UNIX ) FTP configuration, compare it with the one you're using in putty.

The protocol should be the same, but unless you give us your FTP server IP + User/Password we won't be able to test it for you.

The link I posted has the needed configuration and examples on how to connect to an UNIX server using FTP. Just, try it.

OscarRyz
Let me explain in detail what I am looking forI want to copy file from windows to unix machine (correcting my previous question not from unix to windows) using ANT. I thought of using ftp task. Before that as a check I tried to ftp unix sever from windows but it gave connection refused error(Do I need to provide my username and password,if that is the case what is the syntax). But I am able to connect through putty which asks for my user name and password. Does putty uses a different protocol. So if that is the case does ftp task works for me in ANT?. If not what task I need to use?-Thanks
vishu
If you need to add more information to your question, it would be better if you write that in the original question. Click on the "edit" link below your post.
OscarRyz
+1  A: 

Probably the simplest option (if you are going from Windows -> Unix) is the Ant SCP task (which will use the same underlying type of connection PuTTY uses -- SSH). See the Ant SCP Task for details. Note that this will require that you have JSch here: www.jcraft.com/jsch/index.html (I'm limited to one link).

ig0774
i used pscp from command prompt it working,but it is asking for password,i don't want to give my system passwordis there any other way we can do with out password from ant
vishu
Decado's suggestion is very good. The PuTTY documentation here http://the.earth.li/~sgtatham/putty/0.53b/htmldoc/Chapter8.html has some information on setting up SSH keys. However, SSH keys still require a password of some sort. However, it may be simpler to collect the password through another means, e.g., the ant Input task described here: ant.apache.org/manual/CoreTasks/input.html. That would enable the ant build file to be shared among a team, each of whom have a separate login for the unix box. Passwords could also be stored in a properties file specific to the user's machine.
ig0774
A: 

ant scp task can be set up to use passwordless ssh if you set it up with an appropriate key file.

So first make sure you can ssh to the windos server without putting your password into the shell. here is a good set of tutorial for doing it unix to unix http://rcsg-gsir.imsb-dsgi.nrc-cnrc.gc.ca/documents/internet/node31.html . Haven't tried setting up a windows machine, so not too sure how that would work though.

<scp file="file.zip" dir="${userid}@${server}:${remotedir}" keyfile="${env.HOME}/.ssh/id_rsa" passphrase=""/>  
Decado
Okay, got confused with which way round your try to go (windows to unix or unix to windows) Just make sure you can passwordlessly connet to the server in question, using a keyfile and then add that keyfile to the ant task.You will have to exchange keys for this to work.
Decado