about ant sshexec - ant

how to specify command in sshexec task of ant to execute an ant task on a remote server machine. like for example:
<sshexec host="somehost"
username="dude"
keyfile="${user.home}/.ssh/id_dsa"
commandResource="to_run"/>
in above code what would be in the command attribute while trying to perform an ant task on a remote server machine, and also if the ant task is to deploy an application
please help me out on this one as the appache site is not of much help.

Related

sshexec command - ftp get as parametes

In my code am using something like
<sshexec host="somehost"
username="dude"
password="yo"
command="ftp_download"/>
<ftp action="get" server="server_todownload" userid="user" password="aaa" remotedir="dowload/dir">
<fileset dir="${installerdirectory}"><include name="${file_name}"/></fileset>
</ftp>
In "command" of sshexec how i can pass the ftp action as parameters??
is there any example or document is there to get more knowledge??
Thanks in advance
I guess you want to:
ssh to another machine, and
download something on that machine using ftp.
I think you misunderstood something. <sshexec> is a task that sshes to a machine and executes a command on that machine. The command it executes must exist on that machine. For example, your code:
<sshexec host="somehost" username="dude" password="yo" command="ftp_download"/>
There must be a command named ftp_download existing on somehost or your <sshexec> will fail. You can't use an ant task in your local build file as a parameter because <sshexec> doesn't work in this way at all.
Suggestion:
You can put the ftp task in an ant build file, and deploy it to the remote machine (you can use scp task) before sshexec. In sshexec's command, you write ant -f path_to_build_file ftp_target. You need to ensure that there is ant on that machine.

Ant exec task as another user

I would like to execute a shell script from an ant build (I saw the exec task seems to do it), but this script has to be executed from a user different thant the one launching ant. Is there a way to do this?
You could use the sshsexec task. Connect locally or to a remote machine:
<sshexec host="localhost"
username="dude"
password="yo"
command="touch somefile"/>
This task will require the optional jsch.jar to be installed in your ANT lib.
Specifying a pirvate key would enable a password-less login.
Couldn't you execute, from ant, a script that executes the actual script using sudo? See How to pass the password to su/sudo/ssh without overriding the TTY? for how to pass the password from the command line.

ANT how to fork task execution?

I need to fork a new process for a specific ant task. I dont see a fork attribute in the taskdef how do I do it ?
I should be clearer, I am not talking about executing ANT in a forked process:
I have an ant task X, which I need to run in a forked process. Its some third party task which i use with taskdef X and then use this way
Is there anyway to tell any that anytime i use that task please fork the process and run ?
See Running Ant via Java in the Ant manual.

What is the equivalent ant command for export as EAR file and welogic deploy and undeploy command?

I am trying to create a hudson job to perform build of my application.
I like to checking on the following
equivalent ant command for export as EAR file
equivalent ant command for deploy / undeploy for weblogic portal EAR file deployment
To create ear, you would want to use ant ear task.
To deploy in weblogic, you should look at wldeploy ant task

Ant task to automate the start of my server and application

I want to write Ant task to automate the task of starting my server and then open Internet Explorer with the URL of my application.
Obviously I have to execute the startServer task first and then startApplication task.
But Ant is not coming out of startServer task even after starting the server to execute startApplication task.
Basically I want Ant to understand that startServer will not end and ANT has to come out of startServer task and runstartApplication task while startServer task is running in background.
My guess is that you have an exec task in startServer. Add spawn="true" to the exec. Ant will then execute the command in the background and continue without waiting for it to complete.
I agree with Aaron you can use exec to do this, you can also use waitfor to test your connection.
<exec executable="${jboss.startup.bat}" spawn="true"/>
<echo>Waiting to start</echo>
<waitfor maxwait="10" maxwaitunit="second" checkevery="5000">
<!-- try to detect when the server has started -->
<http url="${myurl}" />
</waitfor>
<echo>Started</echo>
You also need to be aware of the problems with exec'ing .bat files directly. Consult the manual page for the <exec> task for more information.

Resources