8 Replies Latest reply on Jul 13, 2012 1:42 PM by monkeybreadsoftware

    SFTP Connection


      I need to write a server-side script which automatically exports a couple of files to a directory on a remote SFTP server. I know how to do this to a local drive. How do I implement the SFTP server share?





        • 1. Re: SFTP Connection

          Your best and probably only bet is to use an FTP plugin.

          • 2. Re: SFTP Connection

            Hi Tom,


            You will need a plugin to upload the files. I use FTPeek from 360works to download from an FTP site. You can check out my post at the NY User group. It's more about debugging server side scripts but you can see the basic script. I am connecting to a standard FTP site but FTPeek supports SFTP as well.




            John Morina

            Pueblo Systems, Inc.

            CCQ-FM, Inc.

            • 3. Re: SFTP Connection

              Hi John,


              Looks nice.  But it costs almost $2,000 for a license to run it as a server-side script.  That's ten times what we can afford.





              • 4. Re: SFTP Connection



                Re-read the licensing...the enterprise license works for server side scripts $395



                • 5. Re: SFTP Connection

                  Looks like you need an enterprise version which is only $395 or you could use the plugin from here: https://secure.comm-unity.net/products.htm


                  which is just over $300. Regardless you need a plug-in this capability is not supported natively by FileMaker. Good luck.

                  • 6. Re: SFTP Connection

                    Tom may need a new shell,


                    I use a shell script to invoke "cURL" (built into the OS) on the Mac to do SFTP file upload and download.

                    cURL is a command line tool for transferring files with URL syntax, supporting FTP, FTPS, TFTP, HTTP, HTTPS, TELNET, DICT, FILE and LDAP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, kerberos), file transfer resume, proxy tunneling and a busload of other useful tricks.


                    Learn more:




                    On Windows you can find the info on-line.

                    Free clients:



                    How to set it up:




                    I've been using this code in a "Send AppleScript" command from FMP7-12 on OSX for a few years and its proven to be reliable.

                    My Example:

                    tell application "Finder"

                         set thePath to container of (path to me) as string

                         set theFile to thePath & "name_of_file_to_downlaod"

                    end tell


                    set ftpSite to "ftp://URL"

                    set ftpUser to "myusername"

                    set ftpPass to "mypassword"


                    set done to simpleFtpDownload(ftpSite, theFile, ftpUser, ftpPass)


                    on simpleFtpDownload(remoteURL, localFile, userName, userPasswd)

                         -- version 1.2, Dan Shockley (http://www.danshockley.com)

                         -- uses curl to do the upload

                         -- remoteURL is the complete ftp url to the remote destination directory


                              set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}

                              set parentFolder to (text items 1 thru -2 of (localFile as string)) as string

                              set AppleScript's text item delimiters to od


                              set localPosixPath to quoted form of POSIX path of localFile

                              set uploadFileName to do shell script "basename " & localPosixPath

                              set uploadDirectory to quoted form of POSIX path of parentFolder


                              -- curl --upload-file SOMEFILE ftp://SERVER.com --user MYUSER:THEPASSWD

                              -- must be IN the directory of the file you want to upload

                              set myCommand to "cd " & uploadDirectory & ";" & " curl -O --url "

                              set myCommand to myCommand & " " & remoteURL & "/"

                              set myCommand to myCommand & uploadFileName

                              set myCommand to myCommand & " --user " & userName & ":" & userPasswd

                              set myCommand to myCommand & " " & "--write-out " & "%"

                              set myCommand to myCommand & " --quote -quit"


                              -- output is the 'size_download' result from curl


                              set uploadResult to do shell script myCommand



                              return uploadResult -- size downloaded in kilobytes

                         on error errmsg number errNum

                              error "simpleFtpDownload FAILED: " & errmsg number errNum

                         end try

                    end simpleFtpDownload

                    • 7. Re: SFTP Connection

                      I have spent some time working on this in the past. My method has been to use Troi File to create a batch script that would control Win SCP - a free SFTP client (See http://winscp.net to download and http://winscp.net/eng/docs/commandline  for docs on command line functionality). There are probably other plug-ins that are able to create a file, but I have always had luck with the troi stuff because the "ExecuteShell" function allows you to receive feedback to monitor success.  You may need to set up your server for login without passwords using private/public keys for unattended and secure use. 




                      Our system uses these batch files to compress files, archive files, track them, load them into a SQL database directly (non-filemaker) and create and delete users via SSH. You can take it a step further and even control your servers using SSH from FileMaker scripting. also use "PLink" which is a command line version of Putty. 

                      Docs on using plink: http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter7.html


                      If you decide to go this route, let me know and I will send you over some of the calcs. There are multiple options such as upload, download, sync folder, etc. to choose from.


                      Jay Knight

                      • 8. Re: SFTP Connection

                        MBS Plugin can do SFTP (and FTPS) for uploading files.


                        One of thousand features: