Hi Stefan,

Here is a patch to add localFile, remoteFile, localTodir and remoteTodir
attributes to scp.
Also included is a patch to add the corresponding documentation.

- rami

Index: Scp.java
===================================================================
RCS file:
/home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.
java,v
retrieving revision 1.15
diff -B -b -u -r1.15 Scp.java
--- Scp.java 7 Apr 2004 13:30:30 -0000 1.15
+++ Scp.java 12 Apr 2004 08:04:00 -0000
@@ -43,6 +43,7 @@
     private String fromUri;
     private String toUri;
     private List fileSets = null;
+    private boolean isFromRemote, isToRemote;
     /**
      * Sets the file to be transferred.  This can either be a remote
@@ -55,6 +56,19 @@
      */
     public void setFile(String aFromUri) {
         this.fromUri = aFromUri;
+        this.isFromRemote = isRemoteUri(this.fromUri);
+    }
+
+    /**
+     * Since setFile() makes the decision whether the file is remote or
local based on whether Uri contains @ character this fails when a local path
contains @ character. Thus explicit attributes to set the file as local or
remote exist.
+    */
+    public void setLocalFile(String aFromUri) {
+        this.fromUri = aFromUri;
+        this.isFromRemote = false;
+    }
+    public void setRemoteFile(String aFromUri) {
+        this.fromUri = aFromUri;
+        this.isFromRemote = true;
     }
     /**
@@ -68,9 +82,20 @@
      */
     public void setTodir(String aToUri) {
         this.toUri = aToUri;
+        this.isToRemote = isRemoteUri(this.toUri);
     }
-
+    /**
+     * Since setTodir() makes the decision whether the dir is remote or
local based on whether Uri contains @ character this fails when a local path
contains @ character. Thus explicit attributes to set the dir as local or
remote exist.
+    */
+    public void setLocalTodir(String aToUri) {
+        this.toUri = aToUri;
+        this.isToRemote = false;
+    }
+    public void setRemoteTodir(String aToUri) {
+        this.toUri = aToUri;
+        this.isToRemote = true;
+    }
     /**
      * Adds a FileSet tranfer to remote host.  NOTE: Either
@@ -102,11 +127,6 @@
                 + "FileSet is required.");
         }
-        boolean isFromRemote = false;
-        if (fromUri != null) {
-            isFromRemote = isRemoteUri(fromUri);
-        }
-        boolean isToRemote = isRemoteUri(toUri);
         try {
             if (isFromRemote && !isToRemote) {
                 download(fromUri, toUri);

Index: scp.html
===================================================================
RCS file: /home/cvspublic/ant/docs/manual/OptionalTasks/scp.html,v
retrieving revision 1.12
diff -B -b -u -r1.12 scp.html
--- scp.html 9 Feb 2004 21:50:08 -0000 1.12
+++ scp.html 12 Apr 2004 08:04:41 -0000
@@ -20,7 +20,7 @@
 in the Ant distribution.  See <a
 href="../install.html#librarydependencies">Library Dependencies</a>
 for more information.  This task has been tested with jsch-0.1.2 to
-jsch-0.1.9.</p>
+jsch-0.1.14.</p>
 <h3>Parameters</h3>
 <table border="1" cellpadding="2" cellspacing="0">
@@ -34,19 +34,39 @@
     <td valign="top">The file to copy.  This can be a local path or a
     remote path of the form <i>user[:[EMAIL PROTECTED]:/directory/path</i>.
     <i>:password</i> can be ommitted if you use key based
-    authentication or specify the password attribute.</td>
+    authentication or specify the password attribute. The way remote path
is recognized is whether it contains @ character or not. This will not work
if your localPath contains @ character.</td>
     <td valign="top" align="center">Yes, unless a nested
     <code>&lt;fileset&gt;</code> element is used.</td>
   </tr>
   <tr>
+    <td valign="top">localFile</td>
+    <td valign="top">This is an alternative for file attribute. But this
must always point to a local file. The reason this was added was that when
you give file attribute it is treated as remote if it contains @ character.
This character can exist also in local paths</td>
+    <td valign="top" align="center">Alternative to file attribute.</td>
+  </tr>
+  <tr>
+    <td valign="top">remoteFile</td>
+    <td valign="top">This is an alternative for file attribute. But this
must always point to a remote file. The reason this was added was that when
you give file attribute it is treated as remote if it contains @ character.
This character can exist also in local paths</td>
+    <td valign="top" align="center">Alternative to file attribute.</td>
+  </tr>
+  <tr>
     <td valign="top">todir</td>
     <td valign="top">The directory to copy to.  This can be a local path
     or a remote path of the form
<i>user[:[EMAIL PROTECTED]:/directory/path</i>.
     <i>:password</i> can be ommitted if you use key based
-    authentication or specify the password attribute.</td>
+    authentication or specify the password attribute. The way remote path
is recognized is whether it contains @ character or not. This will not work
if your localPath contains @ character.</td>
     <td valian="top" align="center">Yes</td>
   </tr>
   <tr>
+    <td valign="top">localTodir</td>
+    <td valign="top">This is an alternative for todir attribute. But this
must always point to a local directory. The reason this was added was that
when you give todir attribute it is treated as remote if it contains @
character. This character can exist also in local paths</td>
+    <td valian="top" align="center">Alternative to todir attribute.</td>
+  </tr>
+  <tr>
+    <td valign="top">remoteTodir</td>
+    <td valign="top">This is an alternative for todir attribute. But this
must always point to a remote directory. The reason this was added was that
when you give todir attribute it is treated as remote if it contains @
character. This character can exist also in local paths</td>
+    <td valian="top" align="center">Alternative to todir attribute.</td>
+  </tr>
+  <tr>
     <td valign="top">port</td>
     <td valign="top">The port to connect to on the remote host.</td>
     <td valian="top" align="center">No, defaults to 22.</td>
@@ -91,6 +111,11 @@
      <td valign="top">Passphrase for your private key.</td>
      <td valign="top" align="center">Yes, if you are using key based
      authentication.</td>
+  </tr>
+  <tr>
+    <td valign="top">verbose</td>
+    <td valign="top">Determines whether SCP outputs verbosely to the user.
Currently this means outputting dots/stars showing the progress of a file
transfer.</td>
+    <td valign="top" align="center">No; defaults to false.</td>
   </tr>
 </table>
 <h3>Parameters specified as nested elements</h3>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to