Administration from the Command Line
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.
Caution
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.
About System Paths
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
Command Line Reference
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.
For a more detailed command-line reference for FileMaker Server, see Chapter 14 of FileMaker 8 Functions and Scripts Desk Reference. |
Command Options
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.
Scripting FileMaker Server Administrative Tasks
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.
Категории |