Results 1 to 2 of 2
Thread: Move remote file using JSCH
- 10-10-2012, 03:53 PM #1
Member
- Join Date
- Oct 2012
- Posts
- 1
- Rep Power
- 0
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?
- 10-11-2012, 08:44 AM #2
Member
- Join Date
- Jul 2012
- Location
- Earth
- Posts
- 75
- Rep Power
- 0
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
-
FTP parsing remote file error
By agangaia in forum New To JavaReplies: 0Last Post: 04-18-2011, 08:45 PM -
Jsch and Secure File Transfer Protocol [SFTP]
By Shivkumar in forum New To JavaReplies: 3Last Post: 01-20-2011, 11:56 AM -
Applet and remote file
By Preethi in forum Java AppletsReplies: 0Last Post: 06-03-2008, 05:54 AM -
File drop zones don't move with window in Firefox
By jazgold in forum Java AppletsReplies: 2Last Post: 01-02-2008, 10:25 PM -
How to Move a File to Another Directory
By Ada in forum New To JavaReplies: 1Last Post: 05-26-2007, 01:17 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks