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: [EMAIL PROTECTED] 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="[EMAIL PROTECTED]:${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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]