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/04 10:22:11 UTC
DO NOT REPLY [Bug 39197] New: - SSHExec task: input property
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=39197>.
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=39197
Summary: SSHExec task: input property
Product: Ant
Version: 1.6.5
Platform: Other
OS/Version: other
Status: NEW
Severity: enhancement
Priority: P2
Component: Optional Tasks
AssignedTo: dev@ant.apache.org
ReportedBy: Markus.Barchfeld@dvag.com
The sshexec task should support an input property in the same was as the output
property. While the output/outputProperty property stores the output (stdout and
stderr) of the remote command in either a file or a property, the
input/inputProperty should allow to supply stdin for the remote command.
The following patch provides an implementation for input/inputProperty:
Index: SSHExecMod.java
===================================================================
RCS file:
/usr/local/cvsveritas/build.maven.dev.tools/src/build/maven/dev/tools/sshmod/SSHExecMod.java,v
retrieving revision 1.1
diff -u -r1.1 SSHExecMod.java
--- SSHExecMod.java 30 Mar 2006 10:47:44 -0000 1.1
+++ SSHExecMod.java 3 Apr 2006 11:13:24 -0000
@@ -17,10 +17,14 @@
package build.maven.dev.tools.sshmod;
+import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
+import java.io.InputStream;
import java.io.StringReader;
import org.apache.tools.ant.BuildException;
@@ -53,6 +57,8 @@
private String outputProperty = null; // like <exec>
private File outputFile = null; // like <exec>
+ private String inputProperty = null; // like <exec>
+ private File inputFile = null; // like <exec>
private boolean append = false; // like <exec>
private static final String TIMEOUT_MESSAGE =
@@ -93,6 +99,24 @@
public void setOutput(File output) {
outputFile = output;
}
+
+ /**
+ * If used, the content of the file is piped to the remote command
+ *
+ * @param input The file which provides the input data for the remote command
+ */
+ public void setInput(File input) {
+ inputFile = input;
+ }
+
+ /**
+ * If used, the content of the property is piped to the remote command
+ *
+ * @param inputProperty The property which contains the input data for the
remote command.
+ */
+ public void setInputProperty(String inputProperty) {
+ this.inputProperty = inputProperty;
+ }
/**
* Determines if the output is appended to the file given in
@@ -134,10 +158,32 @@
if (command == null) {
throw new BuildException("Command is required.");
}
+ if (this.inputFile != null && this.inputProperty != null) {
+ throw new BuildException("You can't specify both inputFile and
inputProperty.");
+ }
+ if (this.inputFile != null && !inputFile.exists()) {
+ throw new BuildException("The input file " +
this.inputFile.getAbsolutePath() + " does not exist.");
+ }
ByteArrayOutputStream out = new ByteArrayOutputStream();
TeeOutputStream tee = new TeeOutputStream(out, System.out);
+ InputStream istream = null ;
+ if (this.inputFile != null) {
+ try {
+ istream = new FileInputStream(this.inputFile) ;
+ } catch ( FileNotFoundException e ) {
+ // because we checked the existence before, this one shouldn't happen
+ // What if the file exists, but there are no read permissions?
+ }
+ }
+ if (this.inputProperty != null) {
+ String inputData = getProject().getProperty(this.inputProperty) ;
+ if (inputData != null) {
+ istream = new ByteArrayInputStream(inputData.getBytes()) ;
+ }
+ }
+
Session session = null;
try {
// execute the command
@@ -147,6 +193,7 @@
channel.setCommand(command);
channel.setOutputStream(tee);
channel.setExtOutputStream(tee);
+ channel.setInputStream(istream) ;
channel.connect();
// wait for it to finish
--
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 39197] - SSHExec task: input property
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=39197>.
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=39197
riznob@hotmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |riznob@hotmail.com
--
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 39197] - SSHExec task: input property
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=39197>.
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=39197
------- Additional Comments From riznob@hotmail.com 2006-04-06 19:02 -------
Created an attachment (id=18035)
--> (http://issues.apache.org/bugzilla/attachment.cgi?id=18035&action=view)
should have left the setInput method name as it was, undid change
After reviewing exec task, I undid the rename of setInput, so it will be
consistent with other tasks.
--
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 39197] - SSHExec task: input property
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=39197>.
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=39197
------- Additional Comments From riznob@hotmail.com 2006-04-06 18:33 -------
Created an attachment (id=18034)
--> (http://issues.apache.org/bugzilla/attachment.cgi?id=18034&action=view)
Diff -u of the suggested change, with a minor change
Renamed the setInput(File file) method to setInputFile(File file). Created diff
-u for patching. Tested both inputproperty and inputfile.
--
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