You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2020/09/16 08:20:39 UTC

[Bug 64742] New: optional task SCP (with sftp=true) fails if fetching file located in root directory

https://bz.apache.org/bugzilla/show_bug.cgi?id=64742

            Bug ID: 64742
           Summary: optional task SCP (with sftp=true) fails if fetching
                    file located in root directory
           Product: Ant
           Version: 1.10.7
          Hardware: PC
            Status: NEW
          Severity: minor
          Priority: P2
         Component: Optional Tasks
          Assignee: notifications@ant.apache.org
          Reporter: fabien.dezempte@stambia.com
  Target Milestone: ---

scp task failed when trying to get a file located in the root directory when
sftp="yes" : 
 com.jcraft.jsch.JSchException: Could not get '/file1.xml' to 'D:\temp\out' -
4: 


With following configuration : 
<project default="scp">
        <target name="scp">
                <scp file="user:password@localhost:/file1.xml" trust="yes" 
sftp="yes" verbose="true" 
                        todir="D:\temp\out\" />
        </target>
</project>


Workaround: add another / to /file1.xml =>
file="user:password@localhost://file1.xml"


Code:
 ScpFromMessageBySftp execute method call getDir:

    String pwd = remoteFile;
    if (remoteFile.lastIndexOf('/') != -1) {
        if (remoteFile.length() > 1) {
            pwd = remoteFile.substring(0, remoteFile.lastIndexOf('/'));
        }
    }
    channel.cd(pwd);


pwd is setted in this cas as an empty string,  channel.cd is executed and fail.


Configuration:
 ant  1.10.7 version
 jsch 0.1.55 version

-- 
You are receiving this mail because:
You are the assignee for the bug.