AnsweredAssumed Answered

Applescript, terminal command, and command results

Question asked by disabled_JustinClose on Feb 19, 2013
Latest reply on Feb 20, 2013 by disabled_JustinClose

Title

Applescript, terminal command, and command results

Post

     I am trying to do some image encoding into base64.  I would like to accomplish all this from inside a FMP database.  I am using FileMaker (ProAd 12.03) on Mac OSX 10.6.8.

     What I have come up with so far:

        There is terminal command that will do the encoding:  openssl

        AppleScript can call a terminal command, and also set a cell value

     I would like to create an AppleScript that IDEALLY would pull the image from a container field in the current record, encode it, and use the result to set another field in the same record to the encoded value.

     I can get the AppleScript part to work, if I edit it in AppleScript Editor:

          do shell script "openssl base64 -in /Users/justin/Documents/shell_scripts/candycane.png"

     This results in the output just going to stdout, which is fine.  I also had a version of the command that output to a file in the file system, but then that would require importing that text file back into FMPro.  Maybe that is easier, but it seemed more elegant to just take the raw result and set that to a field.

     So this is the script that I am fiddling with inside FMPro in a 'Perform AppleScript' script step.  It currently just uses an existing file in the operating system as the input; if someone has ideas on how to take the contents of the container field (an image file) in this record as the input to the AppleScript, that would be appreciated.  The destination field name in the current record is "b64_encoded".

"set encoded to do shell script 'openssl base64 -in /Users/justin/Documents/shell_scripts/candycane.png'

set cell \"b64_encoded\" of current record to encoded"

     I keep getting syntax type errors, however.  I am, obviously, not real sure how to correctly integrate the AppleScript script step into a FMPro calculation box of a script step.

      

     Thanks,

     J

Outcomes