sshexec ant task. How to not show the output

I have a task sshexec in an ant buildfile. This task shows the output of the command i wish to execute. My question is: how to not show the output?

here is my task:

<sshexec verbose="false" failonerror="true"
  trust="yes" host="${app.deploy.server}"
  username="${deploy.user}"
  command="find /home/software/public_html/${app.name} -name *.jar* -exec md5sum {} +"
  password="${deploy.password}"
  output="jarsAtServer.txt" outputproperty="trash" />

Thanks in advance.

Upvotes: 2

Views: 4885

Answers (2)

Justin Rowe
Justin Rowe

Reputation: 2446

The ant sshexec outputs the command it will execute as well as the output of the command. The suppresssystemout (since ant 1.9.0) flag can be used to suppress the output of the command, but the command itself will still be displayed. This might be a problem if you need to pass a password to the command.

In that case you can use the inputproperty to pass data directly to the input of the remote command without it being visible on the screen (or process list).

Refer to the answer to this question for an example how to do this.

Upvotes: 2

perja
perja

Reputation: 641

You can silence the output from sshexec task (or any other task) by using a custom logger:

import org.apache.tools.ant.*;
public class MuteTaskLogger extends DefaultLogger
{
    public void messageLogged(BuildEvent event)
    {
        Task task = event.getTask();
        if (task != null &&
            task.getTaskName().equals(event.getProject().getProperty("mute.task")))
        {
            return;
        }
        super.messageLogged(event);
    }
}

Compile with:

javac -cp ant.jar MuteTaskLogger.java

The task to mute is specified with the property "mute.task":

ant -logger MuteTaskLogger -Dmute.task=sshexec -lib <folder-of-MuteTaskLogger-class>

You can tidy it up by putting MuteTaskLogger into one of the Ant library directories. The logger and mute.task properties can be added to the ANT_ARGS environment variable.

Upvotes: 2

Related Questions