Jump to content

Upload Contents of Container Field to FTP (Mac OS / AppleScript technique)

Recommended Posts

Hi All, 


I just thought I'd try to give back to the community that has given so much to me by writing a little tutorial. This technique is one I developed on Macs. Mac OS X has the curl command line tool as part of the default installation. Curl is like a web swiss army knife. You can fetch files, POST data, upload to or download from FTP servers etc... so it brings a lot of functionality to the table which isn't built into FileMaker. I make use of curl through the "do shell script" AppleScript command, which in FileMaker I use through the "Perform AppleScript" script step. Here's a simple 6 line script that lets you take the contents of a container field and upload it to an FTP site. Substitute your container field in the first and fifth lines and your FTP information in the $script variable to make it functional. This script could be extended by actually having variables for the FTP credentials/location too but I've kept it simple here just to demonstrate the technique.



set variable [$file_name; GetAsText(YourTable::YourContainerField)]

set variable [$path_temp; Get(TemporaryPath) & $file_name]

set variable [$path_unix; Middle($path_temp ; Position($path_temp ; "/" ; 1 ; 2) ; Length($path_temp))]

set variable [$script; "do shell script "curl -T " & $path_unix & " ftp://USERNAME:PASSWORD@FTP_HOST/FTP_DIRECTORY/" & $file_name &"""]

Export Field Contents [YourTable::YourContainerField; "$path_temp"]

Perform AppleScript [$script]



Share this post

Link to post
Share on other sites

This is fantastic, and so simple. It worked for me on the first try. I couldn't believe it. Thank you.

Share this post

Link to post
Share on other sites



The script as-is may not work since as of FileMaker 12 GetAsText(containerField) returns more than just the filename. You may have to look for and remove additional text such as "remote:"

Share this post

Link to post
Share on other sites

Wondering...Is there a Apple script replacement for Windows?

Share this post

Link to post
Share on other sites

Simple - and did just what it is supposed to do!


FMPro 13 allows easier extraction of the container file name, by using the GetContainerAttribute function:

GetContainerAttribute ( GetContainerAttribute ( sourceField ; attributeName ) and substituting "filename" for "attributeName".

Other attributes can easily be read, too, as listed here:



HOWEVER... I suspect that the "curl-T" command has problems with specific characters in the file name.

I have found that the script just hangs if the file name contains spaces, "&", or other such non-UNIX-friendly characters.

Is there a way to overcome this, and still preserve the original filename?

Share this post

Link to post
Share on other sites


I am having trouble entering line 4 in the above script. The value of $script rejects the 'do shell script' as an unrecognised table.

How do we define the script in Filemaker 14

Am I missing something?

Edited by bmcintosh46

Share this post

Link to post
Share on other sites

I believe it needs to be:

"do shell script \"curl -T " & $path_unix & " ftp://USERNAME:PASSWORD@FTP_HOST/FTP_DIRECTORY/" & $file_name & "\""


Share this post

Link to post
Share on other sites

Thanks Comment

It took me a number of hours but I did eventually work this out. Seemed strange to me that other were excited about the script working and yet it wasn't displayed correctly.

Thanks for you time

Share this post

Link to post
Share on other sites
2 minutes ago, bmcintosh46 said:

Seemed strange to me that other were excited about the script working and yet it wasn't displayed correctly.

It probably was displayed correctly back in 2013, but didn't survive all the forum up?grades since.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By ddinisco
      Using the script step export field contents, I can not export the contents of a container field. Error message reads ...could not be created on this disk. use a different name, make more room on the disk or use a different disk. I know I have had this in years past, but I can not remember the fix for this. I found something about setting the fonts to .ttf, but I am on a mac running fmpa16. Any help would be much appreciated.
    • By ddinisco
      I don't see anyway to scrub an audio file like an mp4 or 3 when placed into a container field. It works great if the content is a quicktime movie. It also does not display the time of location in the track (i.e. skip to :37).
      Any way to make this work or work around?
    • By typewriter
      Is it possible to use AppleScript to open the Script Workplace, select a particular script and even scroll to a particular line?
      I looked through several AppleScript sources (there are not so many...) as well as the Dictionary of FIleMaker Pro Advanced 15, but all examples seem to deal with using the database (i.e. finding and manipulating records), not authoring.
      Why would be handy? I have an authoring database where I can store the scripts and scriptsteps of a solution. These are converted from FIlemaker XML using the MBS plugin, not that complicated. Then it's possible to select the scriptsteps that need attention. But locating these scripts in the original solution is quite time consuming, so an AppleScript would save me tons of time.
    • By wedgeman
      So i'm dealing with two tables.
      1.  VisitTable.
      2. GraphicsTable
      in a VisitTable layout, i have one or two portals related to the GraphicsTable, each related by a different factor.  One portal would be related by a Date field, the other would be a ClientName field..
      My desire is to click on a thumbnail in either one of these portals, and have that selected image be displayed in a separate/larger image window (which could be a container field in the current table, Or another portal?  I don't care how - i just need to have it show up) 
      I don't know the best method for doing this (ie., click thumbnail to have image fillin a separate location).  In this particular instance, I don't want this to be a separate window, but to display in a container field view on the current window/layout. 
      how do I accomplish this?

    • By Kent Searight
      I'm trying to get a token from an authorization server using cURL in Insert From URL. When I make the following request in Terminal
      curl -i -X POST -d 'username=myaccountname&password=mypassword' https://authserver.com/login
      I get the token back in the response header.
      Since FileMaker doesn't support the --include (-i) option I haven't been able to figure out how to get the response header with the token.  Anyone have any ideas on how to accomplish this?

      Thanks in advance!
      Okay, I figured out I can get a response header by using the option --dump-header and setting it to a variable. The only problem now is that the token comes from a redirect location and I'm only getting the response header from the original URL. I'll keep working on it but I'll be happy to get whatever advice anyone can offer in the meantime. 

Important Information

By using this site, you agree to our Terms of Use.