I have following groovy code to transfer a xlsx file to a remote SFTP server using JSCH library:
JSch jsch = new JSch();
Session jschSession = jsch.getSession("username", "ip");
jschSession.setConfig("StrictHostKeyChecking", "no");
jschSession.setPassword("password");
jschSession.connect();
def channelSftp = (ChannelSftp) jschSession.openChannel("sftp");
channelSftp.connect();
def remoteDir = "/my/data/"
def remoteFile = remoteDir + "file_with_error" + ".xlsx"
channelSftp.put("/home/.../data/mydata.xlsx", remoteFile);
channelSftp.exit();
So I expect this code to transfer local file mydata.xlsx and put it on remote server at location /my/data/ with name file_with_error.xlsx. There is no such file there at start.
But this gives me error:
2: No such file
What am I missing here?