on ‎2024 Jul 09 9:29 AM
Hi all,
As CPI doesn't come with any standard feature to list files in a directory, I'm using a Groovy script.
// initialize vars
def secureStorageService = ITApiFactory.getApi(SecureStoreService.class, null);
def cred = secureStorageService.getUserCredential(aliasCredentials);
if (cred == null){
// error handling
}
userName = cred.getUsername()
password = new String(cred.getPassword())
def exception = ''
JSch jsch = new JSch();
Session session = null;
try {
session = jsch.getSession(userName, hostName, Integer.valueOf(port));
session.setConfig("StrictHostKeyChecking", "no");
session.setPassword(password);
session.connect();
Channel channel = session.openChannel("sftp");
channel.connect();
ChannelSftp sftpChannel = (ChannelSftp) channel;
InputStream stream = sftpChannel.get(filePath);
sftpChannel.exit();
session.disconnect();
} catch(Exception e) {
exception = e.getMessage()
//Exception Handling
}
// output handlingIt works as long as the SFTP server is on the internet. What if the server is reachable only through SCC? How can I make my Groovy script work?
Regards.
Cristian
Request clarification before answering.
| User | Count |
|---|---|
| 14 | |
| 9 | |
| 7 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.