November 15, 200718 yr Requirements: ScriptMaster for FMP (AWESOME!) Download simpleftp.jar (and put it somewhere you can find it later, like the Groovy lib folder if you have Groovy installed ) Should be in a startup script: (should only be loaded once per FM session, dunno if loading more times will break it or not.) SMLoadJar ( "file://C:/Program Files/Groovy/lib/simpleftp.jar" ) Example code: (shamelessly ripped from the SimpleFTP website) EvaluateGroovy(" import org.jibble.simpleftp.*; def ftp = new SimpleFTP(); //modified this line // Connect to an FTP server on port 21. ftp.connect("ftp.somewhere.net", 21, "username", "password"); // Set binary mode. ftp.bin(); // Change to a new working directory on the FTP server. //ftp.cwd("web"); // Upload some files. ftp.stor(new File("file://C:/Program Files/Groovy/lib/simpleftp.jar")); //ftp.stor(new File("comicbot-latest.png")); // You can also upload from an InputStream, e.g. // Well... I haven't tested this in ScriptMaster and I cannot think // of a reason to use it from Filemaker... But, here is is anyway. //ftp.stor(new FileInputStream(new File("test.png")), "test.png"); //ftp.stor(someSocket.getInputStream(), "blah.dat"); // Quit from the FTP server. ftp.disconnect(); ") Edited November 15, 200718 yr by Guest
November 10, 200916 yr Newbies Hello, I am testing this function and I receive the following result: org.jibble.simpleftp.SimpleFTP@12368df Do you know what it means? Thank You...
November 16, 200916 yr Author Yeah... The newer versions of ScriptMaster don't seem to be compatible with the SimpleFTP.jar. My recommendation is to spring for the 360Works FTP plugin.
September 14, 201015 yr Newbies Hello there, I'm using the Jakarta Commons Net-Library from apache.org for FTP. It works very nice under FM Pro 10 (Win7). Don't know about different versions or platforms. To use it, just download the Library and add commons-net-ftp-2.0.jar to the List of Jar-Files and connect like this: ftp = new FTPClient(); ftp.connect( "ftp.yourhost.com" ); ftp.login( "username", "password" ); You can get the download, further details and examples, as well as a complete javadoc on the following site: http://commons.apache.org/net/ This library is able to deal with several other protocols, e.g. POP3 and SMTP. I haven't tested these features yet though. Regards, Lumpi23
September 14, 201015 yr I've been using this as well for some time. where FM parameters ftp_hostname, ftp_username, ftp_password are the hostname, username, and password. Local filename is local path e.g. C:text.dat, remote_directorypath is e.g. /httpdocs, remote_filename is the remote filename, and mode_bin_or_text is the mode, bin or text for binary or text. I also set two timeouts to 20 seconds so it won't hang (20,000 msec) per below. Presumably, you could also run a java program from FM, by running javac followed by java (no SM plugin required), but the plugin certainly simplifies passing parameters and retrieving results from the JVM. One thing I would like to do with this plugin, is figure out how to use jniwrapper, winapi, etc to get a handle on, and attach to, a webviewer control to permit it to be automated. // NOTE: This uses http://commons.apache.org/net/ // FAQ for commons here: http://wiki.apache.org/jakarta-commons/Net/FrequentlyAskedQuestions import org.apache.commons.net.ftp.FTPClient; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPConnectionClosedException; import org.apache.commons.net.ftp.FTPReply; try { FTPClient connection = new FTPClient(); connection.connect(ftp_hostname); boolean logged = connection.login(ftp_username, ftp_password); if (logged) { connection.setSoTimeout(20000); connection.setDataTimeout(20000); if (mode_bin_or_text=="bin") { connection.setFileType(connection.BINARY_FILE_TYPE); } if (mode_bin_or_text=="text") { connection.setFileType(connection.ASCII_FILE_TYPE); } connection.changeWorkingDirectory(remote_directorypath); connection.enterLocalPassiveMode(); InputStream input; input = new FileInputStream(local_filename); connection.storeFile(remote_filename, input); input.close(); connection.logout(); connection.disconnect(); return"Upload Succeeded"; } else return"Error while connecting to FTP..............."; } catch (Exception e) { return e; }
December 3, 201015 yr I'm trying this code but it doesn't work. After loaded jar files, I've registered this function: RegisterGroovy( "FTPSendFile ( ftp_hostname; ftp_username ; ftp_password ; local_filename ; remote_directorypath ; remote_filename ; mode_bin_or_text )"; " FTPClient connection = new FTPClient(); connection.connect(ftp_hostname); boolean logged = connection.login(ftp_username, ftp_password); if (logged) { connection.setSoTimeout(20000); connection.setDataTimeout(20000); if (mode_bin_or_text=='bin') { connection.setFileType(connection.BINARY_FILE_TYPE); } if (mode_bin_or_text=='text') { connection.setFileType(connection.ASCII_FILE_TYPE); } connection.changeWorkingDirectory(remote_directorypath); connection.enterLocalPassiveMode(); InputStream input; input = new FileInputStream(local_filename); connection.storeFile(remote_filename, input); input.close(); connection.logout(); connection.disconnect(); // Succeded return '1'; } else return 'ERROR'; " ) And then called like: FTPSendFile( "";"testuser";"testpass"; $$MyFile ; "/" ; "example.pdf" ; "bin" ) It returns a blank value, and nothing arrives to the server. Any help?
December 3, 201015 yr Added import classes at the beginning of the script: import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPConnectionClosedException; import org.apache.commons.net.ftp.FTPReply; And now returns a '?' value. Any help?
December 3, 201015 yr Finally worked! RegisterGroovy( "FTPSendFile ( ftp_hostname ; ftp_username ; ftp_password ; local_filename ; remote_directorypath ; remote_filename )"; " import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import org.apache.commons.net.ftp.*; try { FTPClient connection = new FTPClient(); connection.connect(ftp_hostname); boolean logged = connection.login(ftp_username, ftp_password); if (!logged) return "0"; connection.setSoTimeout(20000); connection.setDataTimeout(20000); connection.setFileType(connection.BINARY_FILE_TYPE); connection.changeWorkingDirectory(remote_directorypath); connection.enterLocalPassiveMode(); InputStream input; input = new FileInputStream(local_filename); connection.storeFile(remote_filename, input); input.close(); return "1"; } catch (Exception e) { return e; } " ) Now I'll try to FTPGetFile... :
January 21, 201114 yr FTP get.. doesn't check if the file is actually there but seems to work // FTPget ( ftp_host ; ftp_user ; ftp_password ; remote_path ; local_path ; fm_file ; mode_bin_or_text ) // 11_01_20 JR // v1 // downloads file from fTP site, returns true if successful or false or error import org.apache.commons.net.ftp.* _sep = System.getProperty("file.separator") try { conn = new FTPClient() conn.connect(ftp_host) boolean logged = conn.login(ftp_user, ftp_password) if(logged) { conn.setSoTimeout(20000) conn.setDataTimeout(20000) conn.changeWorkingDirectory(remote_path) conn.enterLocalPassiveMode() fos = new FileOutputStream(local_path + _sep + fm_file) conn.retrieveFile(fm_file, fos) fos.close() conn.logout() conn.disconnect() //return"Download Succeeded.." return true } else { //return"Error while connecting to FTP..............." return false } // end if } catch(Exception e) { return e }
October 28, 201312 yr Hello, Looking for a script to upload files on FTP I found the Xavier 782's script. After loadinf the classes requested I've always an error you can see on the attachment Thanks for your help ! Noël
October 28, 201312 yr Its a copy and paste from the internet problem... Somewhere on the last line is something which looks like a space but isn't Try deleting line 30 and typing it by hand..
Create an account or sign in to comment