So far weve looked at how to configure and administer FileMaker Server with the Server Administration Tool. But many of these tasks can be accomplished at the command line as well, with a command-line utility called fmsadmin thats installed alongside FileMaker Server. If you e comfortable at the command line, you can perform many administrative tasks without going through the graphical SAT. Like the SAT, the fmsadmin tool can administer instances of FileMaker Server that are running remotely, as well as those running on the same machine.
This section assumes that you e fairly familiar with working at the command line on your chosen platform. It also assumes that you have some familiarity with setting system paths, writing batch scripts, and executing scheduled tasks.
Command-line administration is accomplished by passing arguments to the fmsadmin command. Consider the following code:
fmsadmin send -m "You have work to do!"
This command sends the message "You have work to do!" to all clients connected to the database on the local machine.
If youve worked much at the command line, you know that tools such as fmsadmin are easier to use if they e somewhere in the system path. If the command is not somewhere in the system path, it can be invoked only if the full path to the command is specified, as in this example:
/Library/FileMaker Server/Tools/fmsadmin send -m "You have work to do!"
(This is a Mac OS-style path, and the backslashes in the path are necessary to escape the spaces in the FileMaker Server install directory path on the Mac OS.) Alternatively, you can call the command when youve navigated to its installed location by saying
./fmsadmin send -m "You have work to do!"
where the dot (.) indicates the current working directory. Neither of these is very desirable, so its best for the fmsadmin command to be available via the system path.
On Mac OS X Server, this happens automatically. On Mac OS X Server, fmsadmin is installed in /usr/bin, which is generally part of the system path. On regular Mac OS X, as well as Windows, fmsadmin is installed outside the default system paths. In this case, there are two choices: either copy it to a location within the default system path, such as /usr/bin on Mac OS or C:WINNT on Windows, or edit the system path to include the fmsadmin install directory. The latter choice is probably the better option because it keeps the system path directories unencumbered.
The correct way to edit the system paths varies depending on operating system, and each operating system generally provides several ways to accomplish this goal. On Windows, you can choose Start Menu, Settings, Control Panel, and then open the System icon, select the Advanced tab, click the Environment Variables button, and then select and edit the path variable in the System Variables window. On Mac OS, you can edit a file such as /etc/profile to add your custom path commands. (Which file you edit depends on which command shell you and your users are using. If you e not very sure which file to edit, its best to consult with a system administrator.)
A third option, on the Mac OS, is to create a symbolic link to the fmsadmin command from someplace on the system path. This installs a file in the system path that points to the true install location of fmsadmin. Such a command would look like this:
ln -s /Library/FileMaker Server/Tools/fmsadmin /usr/bin/fmsadmin
The FileMaker Server documentation doesn document the command line syntax very well (an odd lapse in whats otherwise a very good document). Instead, it refers you to the online help. Table 25.1 contains a list of all the commands and options you can use with fmsadmin.
Back up databases
fmsadmin BACKUP [FILE...] [PATH...] [-diopuwy]
fmsadmin CLOSE [FILE...] [PATH...] [-imptuwy]
Delete a schedule
fmsadmin delete schedule [SCHEDULE #] [-ipuwy]
Disable plug-ins or schedules
fmsadmin DISABLE TYPE [PLUG-IN #] [SCHEDULE #] [-ipuwy]
Disconnect a client
fmsadmin disconnect client [CLIENT # ] [-impuwy]
Enable plug-ins or schedules
fmsadmin ENABLE TYPE [PLUG-IN # ] [SCHEDULE ] [-ipuwy]
List clients, files, plug-ins, or schedules
fmsadmin LIST TYPE [-ipsuwy]
fmsadmin OPEN [FILE...] [PATH...] [-ipuwy]
fmsadmin PAUSE [FILE...] [PATH...] [-ipuwy]
fmsadmin RELOAD [-ipuvwy]
Resume paused databases
fmsadmin RESUME [FILE...] [PATH...] [-ipuwy]
Run a schedule
fmsadmin RUN SCHEDULE [SCHEDULE # ] [-ipuwy]
Send a message
fmsadmin SEND [-cimpuwy] [CLIENT # ] [FILE...] [PATH...]
Show status of guests and files
fmsadmin STATUS TYPE [-ipuwy] [ID # ] [FILE]
Shut down the server
fmsadmin STOP [-fimptuwy]
For a more detailed command-line reference for FileMaker Server, see Chapter 14 of FileMaker 8 Functions and Scripts Desk Reference.
Command options are additional parameters you can add to a command invocation to alter its behavior. The fmsadmin tool supports a number of standard options, and also several options that apply only to certain specific commands. The Usage column in each of the previous descriptions lists possible command options in square brackets. Many options have a long form that appears preceded by a double hyphen. The long form can be used to increase readability, for example, in scripts. See Table 25.2 for the available options.
Print the usage page
-i address, --ip address
Specify the IP address of a remote server
-p pass, --password pass
Password to use to authenticate with the server
-u user, --user user
Username to use to authenticate with the server
-w seconds, --wait seconds
Specify time in seconds for command to time out
Print the version information
Automatically answer "yes" to all prompts
-d PATH, --dest PATH
Specify a destination path for a backup
Close databases or shut down the server forcefully, without waiting for clients to disconnect gracefully
-m message, --message message
Specify a text message to send to clients
Perform an offline backup
Return additional detail about clients or files
-t secs, --grace-time secs
Specify time in seconds before clients will be forcibly disconnected
Using the capabilities of the fmsadmin tool, an experienced system administrator can use command-line scripts to control many aspects of FileMaker Server functioning. These scripts may be executed manually, or run at scheduled times via a system utility such as cron (Mac OS) or the Task Scheduler (Windows). As youll see further on, in the section "Scheduled Tasks," FileMaker Server can also be configured to run system scripts on a schedule.
Using scripted administration, you can even perform a few tasks that cannot directly be performed via the SAT. Suppose that you have a database system with several distinct files. The database is partitioned into different files because different tables in the database have widely differing usage patterns. One very large table is read-only, and consists of data thats imported nightly from another system. Other tables are smaller, but are updated constantly and contain critical data. Youd like to back up the smaller tables once an hour, but the larger table can be backed up as infrequently as once a day. If you establish a FileMaker Server backup schedule via the SAT, each schedule must back up an entire directory at a timeyou can pick and choose among files within a directory. It would be easy enough to put the large file in one directory, the smaller files in another, and establish FileMaker Server-based backup schedules. If this organization is not desirable, though, you need to write two backup scriptsone for the large file, another for the smaller filesand use the operating systems task scheduling facilities to run them at different times. Each script would be fairly simple. They might look like this:
#hourly backup script for the transaction files fmsadmin backup transaction.fp7 customer.fp7 orders.fp7 #daily backup script for the products file fmsadmin backup product.fp7
You could also extend the scripts to use other operating system facilities. For example, you could compress the files after they had been backed up, or notify an administrator via email if the backup failedneither of which is possible with FileMaker Server backups established via the SAT.
Part I: Getting Started with FileMaker 8
Using FileMaker Pro
Defining and Working with Fields
Working with Layouts
Part II: Developing Solutions with FileMaker
Relational Database Design
Working with Multiple Tables
Working with Relationships
Getting Started with Calculations
Getting Started with Scripting
Getting Started with Reporting
Part III: Developer Techniques
Developing for Multiuser Deployment
Advanced Interface Techniques
Advanced Calculation Techniques
Advanced Scripting Techniques
Advanced Portal Techniques
Debugging and Troubleshooting
Converting Systems from Previous Versions of FileMaker Pro
Part IV: Data Integration and Publishing
Importing Data into FileMaker Pro
Exporting Data from FileMaker
Instant Web Publishing
FileMaker and Web Services
Custom Web Publishing
Part V: Deploying a FileMaker Solution
Deploying and Extending FileMaker
FileMaker Server and Server Advanced
Documenting Your FileMaker Solutions
Special Edition Using FileMaker 8
Authors: Scott Love, Steve Lane
The Lean Six Sigma Pocket Toolbook. A Quick Reference Guide to Nearly 100 Tools for Improving Process Quality, Speed, and Complexity