You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2006/04/03 13:06:40 UTC
DO NOT REPLY [Bug 39186] New: - SSHExec task: output disappears
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39186>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39186
Summary: SSHExec task: output disappears
Product: Ant
Version: 1.6.5
Platform: Other
OS/Version: other
Status: NEW
Severity: normal
Priority: P2
Component: Optional Tasks
AssignedTo: dev@ant.apache.org
ReportedBy: Markus.Barchfeld@dvag.com
The output of a remotely executed command does not appear reliably. It seems as
if only the first usage of sshexec within a built logs the output of the remote
command.
The following build file part reveals the error:
<target name="copyScript">
<property name="local.test.script" value="C:\Temp\test.sh"/>
<echo file="${local.test.script}">
echo "Output to stdout"
echo "Output to stderr" 2>&1
</echo>
<scp file="${local.test.script}"
remoteTofile="user@${remote.host}:${remote.test.script}" trust="true"
keyfile="${user.home}/.ssh/id_dsa" passphrase=""/>
</target>
<target name="sshExecOrgStdoutStderr" depends="copyScript">
<sshexec host="host" username="user" command="sh
${remote.test.script}" trust="true" keyfile="${user.home}/.ssh/id_dsa"
passphrase="" outputProperty="ssh.out"/>
<echo message="Stdout/stderr: ${ssh.out}"/>
<sshexec host="host" username="user" command="sh
${remote.test.script}" trust="true" keyfile="${user.home}/.ssh/id_dsa"
passphrase="" outputProperty="ssh.out"/>
<echo message="Stdout/stderr: ${ssh.out}"/>
</target>
The output of this build target is:
sshExecOrgStdoutStderr:
[sshexec] Connecting to host:22
[sshexec] Output to stdout
[sshexec] Output to stderr
[echo] Stdout/stderr: Output to stdout
[echo] Output to stderr
[sshexec] Connecting to host:22
[echo] Stdout/stderr: Output to stdout
[echo] Output to stderr
The lines
[sshexec] Output to stdout
[sshexec] Output to stderr
should also appear for the second call to sshexec. The outputProperty is not
affected.
Here is a patch which uses the LogOutputStream in order to solve the issue.
--- SSHExecMod.java 31 Mar 2006 07:25:55 -0000 1.2
+++ SSHExecMod.java 3 Apr 2006 10:54:50 -0000
@@ -25,10 +25,13 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintStream;
import java.io.StringReader;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.LogOutputStream;
import org.apache.tools.ant.taskdefs.optional.ssh.SSHBase;
import org.apache.tools.ant.util.TeeOutputStream;
@@ -166,7 +169,7 @@
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
- TeeOutputStream tee = new TeeOutputStream(out, System.out);
+ TeeOutputStream tee = new TeeOutputStream(out, new LogOutputStream
(this, Project.MSG_INFO));
InputStream istream = null ;
if (this.inputFile != null) {
@@ -192,7 +195,7 @@
final ChannelExec channel = (ChannelExec) session.openChannel
("exec");
channel.setCommand(command);
channel.setOutputStream(tee);
- channel.setExtOutputStream(tee);
+ channel.setExtOutputStream(new TeeOutputStream(out, new
LogOutputStream(this, Project.MSG_ERR)));
channel.setInputStream(istream) ;
channel.connect();
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
DO NOT REPLY [Bug 39186] - SSHExec task: output disappears
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39186>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39186
bodewig@apache.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |DUPLICATE
Target Milestone|--- |1.7
------- Additional Comments From bodewig@apache.org 2006-04-12 20:24 -------
*** This bug has been marked as a duplicate of 36302 ***
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org