Results 1 to 2 of 2
  1. #1
    psilber is offline Member
    Join Date
    Oct 2012
    Rep Power

    Default Move remote file using JSCH

    I need to move a remote file into a subdirectory using the JSCH library for SFTP. I tried a simple ChannelSftp.rename(filename, subdir + File.separator + filename), but as a result I get the file renamed to subdir+filename in the same directory. Any hint, how this can be done?

  2. #2
    sabre150 is offline Member
    Join Date
    Jul 2012
    Rep Power

    Default Re: Move remote file using JSCH

    I don't know whether or not it will make any difference but to quote section 6.2 (File names) in draft-ietf-secsh-filexfer-02 ( which is what OpenSSH conforms to ) -
    "This protocol represents file names as strings. File names are
    assumed to use the slash (’/’) character as a directory separator."
    so one should use a '/' not File.separator . Note - this will not allow you to move a file from one volume to another; only to rename a file on a a volume.

    I have been working with the SFTP specification for a couple of months and very early on I realised that the specifications are written round what had already been implemented in *Nix and not what should be implemented. There is no attempt to abstract features so that a sensible implementation on OS other than *Nix can conform. The biggest example of this is the specification of the 'longname' files in entries in file lists i.e.

    "The recommended format for the longname field is as follows: -rwxr-xr-x 1 mjos staff 348911 Mar 25 14:29 t-filexfer
    1234567890 123 12345678 12345678 12345678 123456789012"

    which is what one gets from the *Nix 'ls' command and assumes an 'owner/group/world' that just is not available on Windows and using pre-1.7 JDK is not available in Java even for *Nix.
    Last edited by sabre150; 10-11-2012 at 08:48 AM.

Similar Threads

  1. FTP parsing remote file error
    By agangaia in forum New To Java
    Replies: 0
    Last Post: 04-18-2011, 08:45 PM
  2. Jsch and Secure File Transfer Protocol [SFTP]
    By Shivkumar in forum New To Java
    Replies: 3
    Last Post: 01-20-2011, 12:56 PM
  3. Applet and remote file
    By Preethi in forum Java Applets
    Replies: 0
    Last Post: 06-03-2008, 05:54 AM
  4. File drop zones don't move with window in Firefox
    By jazgold in forum Java Applets
    Replies: 2
    Last Post: 01-02-2008, 11:25 PM
  5. How to Move a File to Another Directory
    By Ada in forum New To Java
    Replies: 1
    Last Post: 05-26-2007, 01:17 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts