I have do the following using the Ant.
I need to run the ant script from machine A, the script has the details about the machine B like host name, username, pwd, directory to download, ftp details etc and When the script ran from machine A it should download the somefile using ftp in machine B.
I have given the details about the machine B in script, but when i ran the script it downloads the file in machine A instead of machine B. what i’m missing? or can some one help me with the code?
Thanks in advance.
Here is the code:
In maven i have defined the machine B details:
<host>MachineB</host>
<host.username>user</host.username>
<host.password>pwd</host.password>
In build.xml
<target name="Todownload_file" <mkdir dir="${download_dir}" />
<ftp action="get" server="download_server_details" userid="user" password="pwd" remotedir="path">
<fileset dir="${download_dir}">
<include name="${file_name}"/>
</fileset>
</ftp>
</target>
As i said in the comments, there is no link between the machine b details and the ftp download section. Can anyone help on this?
You can use sshexec task to run remote commands and you can use sep to copy/push files from/to machine B. There are a few ways you could do this conceptually.
First approach:
Download the file from the remote ftp site onto machine A then copy it to Machine B using the scp task. Finally run the file on machine B using sshexec.
Second approach:
Download the file directly onto Machine B by running the curl or ftp commands directly on Machine B from Machine A via sshexec. Then run another sshexec task to execute the file on Machine B.
Third approach:
Write a script (workflowscript.sh) that would work on Machine B (bash for Mac/Linux powershell/VBScript for Windows) and in this script you put the logic to perform the download of the other script via ftp or curl or whatever. Use scp on Machine A to copy workflowscriipt.sh to Machine B then use sshexec to execute it.
In all above approaches you need to be aware of what runs where. Machine A just pushes files or sends remote commands to machine B and machine B does all the work.