Hi,
1:
in the FAQ is read that ftp is available as a resource. I don't see that however in the Designer.
2:
What about sftp?
sftp
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 118
- Joined: Tue Oct 23, 2012 7:01 am
- Location: The Netherlands
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
Harry,
1. We have a Custom Resource that can be used for ftp. It's supplied on an "as is" basis and not officially supported. If you're interested please send an email to support (support@ebasetech.com).
2. We don't have anything for sftp. I see there is a Java library from Apache commons that supports this and I would advise using this. You can call this directly from a Javascript script.
Regards
Jon
1. We have a Custom Resource that can be used for ftp. It's supplied on an "as is" basis and not officially supported. If you're interested please send an email to support (support@ebasetech.com).
2. We don't have anything for sftp. I see there is a Java library from Apache commons that supports this and I would advise using this. You can call this directly from a Javascript script.
Regards
Jon
0 x
-
- Ebase User
- Posts: 118
- Joined: Tue Oct 23, 2012 7:01 am
- Location: The Netherlands
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
Yes, it's possible, but again you need to use Java code to do this. Type it into google and you will see many examples. Executing .bat and .exe files is supported in native Java and there is also an Apache commons library http://commons.apache.org/proper/common ... index.html.
You might find it's less work to use the Apache sftp package. I've never done this, so hard to judge which is the best route.
Regards
Jon
You might find it's less work to use the Apache sftp package. I've never done this, so hard to judge which is the best route.
Regards
Jon
0 x
-
- Ebase Staff
- Posts: 89
- Joined: Mon Sep 10, 2007 11:48 am
Hi Harry,
I've used the Apache Commons library for FTP (not SFTP though), but I imagine it's very similar. Here's a bit of sample code:
Sorry about the blah, blah in the code but hopefully you can see the basics around opening a connection to an FTP server and streaming files.
Very easy, all you need to do is add the Apache jars to tomcat/lib and you're away.
Cheers,
Dave
I've used the Apache Commons library for FTP (not SFTP though), but I imagine it's very similar. Here's a bit of sample code:
Code: Select all
importPackage(com.ebasetech.xi.api);
importPackage(com.ebasetech.xi.services);
importPackage(java.io);
importPackage(org.apache.commons.net.ftp);
// set up FTP connection
var c = new FTPClient();
// download files to master
var serversDL = tables.WZ_SERVERS.rows;
while (serversDL.next()) {
if (tables.WZ_SERVERS.MASTER.value != 'Y') {
// connect to servant's FTP server
writeLog(logName,'Connecting to FTP server on server ' + tables.WZ_SERVERS.SERVER_ID.value + '...','INFO');
c.connect(tables.WZ_SERVERS.DOMAIN.value);
c.login(tables.WZ_SERVERS.USERNAME.value, tables.WZ_SERVERS.PASSWORD.value);
writeLog(logName,'FTP connection successful','INFO');
// get the list of files to be retrieved
writeLog(logName,'----------------------------','INFO');
writeLog(logName,'Getting file list for server '+tables.WZ_SERVERS.SERVER_ID.value,'INFO');
var p = {};
p.SYNCH_ID = fields.SYNCH_ID.value;
p.SERVER_ID = tables.WZ_SERVERS.SERVER_ID.value;
var rows = tables.WZ_SYNCH_FILELIST.findRows(p);
// retrieve each file via FTP and write to master's local file system
writeLog(logName,'Download of files from server '+tables.WZ_SERVERS.SERVER_ID.value+' begins','INFO');
while (rows.next()) {
// replace filename back slashes with forward slashes, remove the absolute path reference for the FTP call
var fn = processFilenames(tables.WZ_SYNCH_FILELIST.FILENAME.value);
var dlf = fn[0];
var filename = fn[1];
// set up output stream for file to be written locally
var fos = new FileOutputStream(filename);
// fetch the file from the FTP server
writeLog(logName,'Retrieving file ' + dlf + ' from server ' + tables.WZ_SERVERS.SERVER_ID.value + ' and updating master server','INFO');
c.retrieveFile(dlf, fos);
writeLog(logName,'File retrieval and update successful','INFO');
// close output stream
fos.close();
}
c.disconnect();
writeLog(logName,'Download of files from server '+tables.WZ_SERVERS.SERVER_ID.value+' completed','INFO');
}
}
writeLog(logName,'Download of all files from all servants to master completed','INFO');
writeLog(logName,'***********************************************************','INFO');
Very easy, all you need to do is add the Apache jars to tomcat/lib and you're away.
Cheers,
Dave
0 x
-
- Ebase User
- Posts: 118
- Joined: Tue Oct 23, 2012 7:01 am
- Location: The Netherlands
Who is online
Users browsing this forum: No registered users and 14 guests