I have windows machine with running ssh server. I know the path on that machine. Let it be D:/Folder1/Folder2
. I'm creating sftp channel using JSCH. But when i try to cd to D:/Folder1/Folder2
, "No such file: 2"
error is throwed.
can anyone please help? May be i need to convert path?
I've solved the problem by using ChannelExec by opening exec channel. This worked for me. Hope will work for others too.
...
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
JSch ssh = new JSch();
session = ssh.getSession(sshSolrUsername, sshSolrHost, 22);
session.setConfig(config);
session.setPassword(sshSolrPassword);
session.connect();
channel = session.openChannel("exec");
((ChannelExec)channel ).setCommand("cd " + sourcePath);
exec.setInputStream(null);
((ChannelExec)channel ).setErrStream(System.err);
InputStream in = channel .getInputStream();
channel .connect();
int status = checkStatus(channel , in);
channel.disconnect();
...
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments