HI,
I am trying to ftp a file from one solaris to another solaris box. but when i run the code, i get an SSH exception saying that "The SFTP subsystem could not be intialised".
Btw i am able to manually SFTP the server. for this i give the command as
sftp -s /usr/local/libexec/sftp-server userid@servername
password: pwd
and it takes me to sftp mode.
but i want to do this programmatically. below is the code i have written for this
import java.io.IOException;
import com.enterprisedt.net.ftp.FTPException;
import com.enterprisedt.net.ftp.ssh.SSHFTPClient;
import com.enterprisedt.util.debug.Level;
import com.enterprisedt.util.debug.Logger;
public class pocSFTP {
public static void main(String args[]){
String serverName = "servername";
String userId = "userid";
String password = "pwd";
String destPath = "path is valid";
String localPath = "local path is also valid";
String filename = "file11.txt";
try {
Logger.setLevel(Level.ALL);
SSHFTPClient ftp = new SSHFTPClient();
ftp.setRemoteHost(serverName);
ftp.getValidator().setHostValidationEnabled(false);
ftp.setRemotePort(22);
ftp.setAuthentication(userId,password);
ftp.connect();
ftp.chdir(destPath);
ftp.put(localPath,filename);
ftp.quit();
}catch(IOException Ie){
Ie.printStackTrace();
}catch(FTPException fe){
fe.printStackTrace();
}
}
}