FREE DEMO: The Continued, Steady Power of the Command Line

THE COMMAND LINE OFTEN GETS OVERLOOKED

In a world of expanding API integrations and Claris Connect workflows, the command line is one tool that often gets overlooked. One of our recent projects needed to perform some video editing tasks using videos stored in the Claris FileMaker solution. Our first reaction was to start looking into some APIs to perform the specified tasks and while researching that I was reminded of FFmpeg. Back when I worked in a graphic design shop (many, many moons ago), FFmpeg was a new tool that did a number of basic image and video editing tasks like changing resolution and transcoding all sorts of file types. Fast forward to today, and FFmpeg is the leading open-source standard for processing video and audio, used by everyone from YouTube to VLC.

FFmpeg is a robust tool, but can only be accessed via the command line. In order to interact with it, the solution needed to build the commands in FileMaker, then call upon the power of FFmpeg to execute the commands and return the result back into the FM solution. For some cases, the FFmpeg result was a mp4 file that needed to be stored in a container field. For others, the result was the command output in the form of a log file, used to verify whether the command was successful or not. In order to achieve this call and response between FileMaker and Terminal/CMD, I needed to dust off the old terminal fingers and “grease the hinges”, so to speak.

For those of us old enough to experience the “manual” days of the computer, the command line was everything.

Yours truly, Joe

 

As the years went by and UX design became cohesive with the OS, command line tools became a thing of the past. With that said, today’s use of this tool is still very prevalent, but because it diverts from the forefront interface, it’s often a less preferred option. The “data file” script steps introduced in FileMaker 18 are used to read the output of the command line, which is key in making that transaction as seamless as possible.

SIMPLE COMMAND LINE TASKS

Some of the easiest commands to use are often the most basic. Here are a few of my most commonly used commands in this category. I’ve created a demo file for you to download, to see the starred commands in action. You’ll find a demo button at the bottom of this article.

  • Get a list of files and folders in a directory*

  • Finding the location of a specific file*

  • Move files/folders around

  • Checking drive space*

  • Locking/Unlocking secure drives

  • IP information*

  • Zip/unzip files

*Examples included in demo file

 

COMMAND TOOLS

As with any dev environment, there are a number of free tools that add a number of benefits to your local environment.

  • Broot combines many of the file-finding commands into an easy-to-use tool for searching and viewing directories.

  • Originally a command-line tool, git is the definitive tool for version control. We can only hope that FileMaker will someday integrate git into its environment.

  • Autojump is a handy tool for navigating to your most used directories. I typically use it to jump to my downloads folder or to the FM temp directory.

TIPS AND TRICKS

When I’m building command strings for FileMaker, I’ve learned to standardize a few processes to smooth out the transition between FileMaker and Terminal/CMD. For me, the most integral part of the process is feeding the output back into FileMaker. I know there are a number of ways to achieve this, but my standard has been to output the result into a text file, in the FM temp directory, then grab the contents of the text file. This is achieved by sending the result from the command, to a text file, using “> $PathToTextFile” in the string, then reading the text file using the “Read from data file” script step. For example, in the demo file, the script “Get_Output” has been standardized so all that’s needed is the path to the log file. The script handles the rest.

ONE CAVEAT

In Windows, the text file is kept open until FileMaker exits, so the only work-around that I’ve found is to delete the text file before writing a new one.

ALWAYS EXIT THE TERMINAL/CMD

Another part of making that seamless transition is to always exit the Terminal/CMD and return the user back to the FileMaker solution. This is achieved by appending the “&& exit” to the end of the command string, which tells Terminal/CMD to exit and close the window after the command is executed.

Since the experience differs between Mac and Windows systems, there are two different actions needed to return to FileMaker. On a Mac, commands are sent to Applescript, which then tells Terminal to execute the given command string. The FileMaker script then performs another Applescript command to make FileMaker Pro the active program.

In Windows, the “Send Event” script step has an option to “Bring Target Application to Foreground”. Typically, I’ll leave this setting unchecked, but for the sake of this demo there are separate calls for both keeping the CMD window active and exiting after completion.

ENDLESS POSSIBILITIES

The examples in this post are just a sliver of what’s possible by integrating commands into a FileMaker solution. The demo file included with this post has a few example commands from above. All of the scripts specific to this demo are unlocked and can be quickly copied into any FileMaker solution.

We’d love to hear from the dev community! What kind of commands have you integrated into your FileMaker solutions? Do you have any tips and tricks to share? Please let us know in the comments!

 

ASK YOUR QUESTIONS

If you have any questions or need some assistance getting commands into your solution, please feel free to reach out. You can also catch one of our Office Hours sessions. We’re in Zoom every 1st and 3rd Thursday, from 1-2pm Pacific, to discuss anything related to Claris FileMaker and how it can improve your workflows.


DISCLAIMER

The demo file expects the default shell and directory permissions, so any modifications to your current environment may throw a wrench into the gears of the demo.

2 thoughts on “FREE DEMO: The Continued, Steady Power of the Command Line”

  1. Hi Joe,
    thanks for your very helpful FREE DEMO: The Continued, Steady Power of the Command Line.
    Trying to discover all secrets of this demo file, I noticed that I login with account “demo”, but this account has no full access.
    Are you willing to share a full access name and password?
    Thanks in advance…

    1. Hi Carlo, and thank you for your comment. We aren’t able to provide full access. But the functions necessary to show the demo are unlocked. This includes all layouts and scripts inside the “CMD Demo” folder.

Leave a Reply

Your email address will not be published. Required fields are marked *