Last active
February 3, 2023 01:31
-
-
Save ilessing/67d0a8e84800b0a8a533e15ca5e1fbbc to your computer and use it in GitHub Desktop.
Revisions
-
ilessing revised this gist
Feb 3, 2023 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -36,19 +36,19 @@ In the FileMaker "Perform AppleScript" Options box I selected "Calculated AppleS ``` Specify Calculation Screenshot:  in the above "calculation" I have mostly applescript carefully quoted and with paragraph marks and ampersands to join lines. I'm starting the Filemaker script with a button but you could start it however you like in FileMaker. Button Setup screenshot:  Script Workspace screenshot:  #### Note: - in the Applescript there is a `do script` step. Note this is a Terminal specific command which I found in the Terminal Applescript dictionary. Don't confuse this step with the similarly named Applescript command `do shell script` -
ilessing revised this gist
Feb 3, 2023 . 4 changed files with 68 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,68 @@ # How to pass a FileMaker field value to a shell script on MacOS using Applescript ### Description: Say you have a FileMaker database and you have a field whose value you wish to pass to a shell script on your Mac. The Filemaker client is running on MacOS. It doesn't matter if the Filemaker database is local (on the Mac) or the FileMaker database is hosted on a FileMaker server. I had a "barcode" field and needed to pass that barcode to a shell script as a parameter (or argument). Well the good news is this CAN be done but the syntax is not particulary easy to figure out especially if you're not fluent in Applescript and/or FileMaker. ### Requirements: - I did not want the shell script to run _faceless_ in the background. I wanted the shell script to open in Terminal so the shell script output would be visible. ### Prerequisites and assumptions for my example: - the FileMaker data table is called "test" and has a field with name "barcode" which is a Text field and the value is a simple string without any spaces. - the Shell Script is in the user's home directory. - the Shell script is executible: `chmod +x myShellScript.sh` #### FileMaker script: In my FileMaker layout I added a button which has an "action" set to perform a script and no script Parameter is set. In this script add a script step to "Perform Applescript" In the FileMaker "Perform AppleScript" Options box I selected "Calculated AppleScript" and specified the following calculation: ``` "tell application \"Terminal\"¶" & "activate¶"& "do script \"$HOME/myShellScript.sh "& test::barcode & " \"¶"& "end tell" ``` Specify Calculation Screenshot:  in the above "calculation" I have mostly applescript carefully quoted and with paragraph marks and ampersands to join lines. I'm starting the Filemaker script with a button but you could start it however you like in FileMaker. Button Setup screenshot:  Script Workspace screenshot:  #### Note: - in the Applescript there is a `do script` step. Note this is a Terminal specific command which I found in the Terminal Applescript dictionary. Don't confuse this step with the similarly named Applescript command `do shell script` - _Out of Scope_ for this project was any automatic returning of data or status from the shell script back to FileMaker. I understand there are ways to do this but I did not need to for this use case. #### Reference: - [Claris Community - Using a variable within an AppleScript within a FileMaker script](https://community.claris.com/en/s/question/0D50H00006h9KRLSA2/using-a-variable-within-an-applescript-within-a-filemaker-script) Thanks _nicolai_ from 2017 - [Claris Community - Sending FileMaker variables to perform applescript function](https://community.claris.com/en/s/question/0D50H00006dslQbSAI/sending-filemaker-variables-to-perform-applescript-function) 2018 - [Claris Community - Using FileMaker Variable in an AppleScript](https://community.claris.com/en/s/question/0D50H00006h9MLvSAM/using-filemaker-variable-in-an-applescript) 2017 - Apple Developer [Technical Note TN2065 do shell script in AppleScript](https://developer.apple.com/library/archive/technotes/tn2065/_index.html) - [Mac Automation Scripting Guide: Calling Command-Line Tools](https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/CallCommandLineUtilities.html#//apple_ref/doc/uid/TP40016239-CH43-SW1) --- Initial date: 2023-01-29 LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed.LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed.LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed. -
ilessing renamed this gist
Feb 2, 2023 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ilessing created this gist
Feb 2, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ How to pass a FileMaker field value to a shell script on MacOS using Applescript