FAQ: Building a Database from the Command Line


How do I build a database from the command line?

Short Answer

Run "executable -p profilename -a bd" from the command line window of your operating system.

Long Answer

It is not necessary to use the web interface to build a database; you can use the command line. This is useful for debugging problems with profiles, or for building when the web interface is not available, e.g. from scripts. The exact method, and the exact command, depends on the platform; see below. See also Additional Notes For All Platforms.

Windows

To build a database from the command line, first open a command prompt window. One method to open a command prompt window (sometimes called a DOS window) is to click "start" in the windows task bar then click "run", enter "cmd" in the text box and hit return.

You will get a new window that will display something like this:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\username>

In the command prompt window you will need to move to the Sawmill installation directory using the "cd" command. Sawmill is installed by default to "C:\Program Files\Sawmill 8", to move to this directory type cd C:\Program Files\Sawmill 8 or whatever path you specified during installation.

C:\Documents and Settings\username >cd 'C:\Program Files\Sawmill 8\

C:\Program Files\Sawmill 8>

To get a list of internal profile names type the command "Sawmill.exe -a lp" at the command prompt. This will display a list of the internal profile names from which you can select the profile you want to build.

C:\Program Files\Sawmill 8>Sawmill.exe -a lp
Sawmill 8.0.0; Copyright (c) 2008 Flowerfire
myprofile

To build you will run Sawmill with the "-p profilename -a bd" options. Replace profilename with the internal name of your profile from the list of internal profile names. The build command and related output are shown below. If you wanted to update your database you can run Sawmill with the -p profilename a ud options.

C:\Program Files\Sawmill 8>Sawmill.exe -p myprofile -a bd
Sawmill 8.0.0; Copyright (c) 2008 Flowerfire
 Reading log file: C:\Apache       [                    ] 0.00%  00:00
 Reading log file: C:\Apache       [-                   ] 3.16%  00:01
 Reading log file: C:\Apache       [######-             ] 33.33% 5000e 00:02
 Building cross-reference table 4 (worm)             [#############       ] 66.67%  00:03
 Building cross-reference table 12 (search_engine)  [##############=     ] 73.68% 00:04
 Building cross-reference table 18 (server_response) [####################] 100.00%  00:05

Mac OS X

To build a database from the command line, first open a terminal window. On Mac, you do this by selecting the Finder, navigating to the Applications folder, Utilities, and double clicking the Terminal application.

You will get a new window that will display something like this:

Last login: Mon Sep 1 10:46:44 on ttyp1
Welcome to Darwin!
[host:~] user%

In the terminal window you will need to move to the Sawmill installation directory using the "cd" command. Typically Sawmill is located in "/Applications/Sawmill". If you installed Sawmill somewhere else, change the directory name in the command to match. To move to this directory type "cd /Applications/Sawmill":

[host:~] user% cd /Applications/Sawmill
[host:/Applications/Sawmill] user%

To get a list of internal profile names type the command "./sawmill -a lp" at the command prompt. This will display a list of the internal profile names from which you can select the profile you want to build.

[host:/Applications/Sawmill] user% ./sawmill -a lp
Sawmill 8.0.0; Copyright (c) 2008 Flowerfire
myprofile

To build you will run Sawmill with the "-p profilename -a bd" options. Replace profilename with the internal name of your profile from the list of internal profile names. The build command and related output are shown below. If you wanted to update your database you can run Sawmill with the -p profilename a ud options.

[host:/Applications/Sawmill] user% ./sawmill -p myprofile -a bd
Sawmill 8.0.0; Copyright (c) 2008 Flowerfire
 Reading log file: /logs/Apache       [                    ] 0.00%  00:00
 Reading log file: /logs/Apache       [-                   ] 3.16%  00:01
 Reading log file: /logs/Apache       [######-             ] 33.33% 5000e 00:02
 Building cross-reference table 4 (worm)             [#############       ] 66.67%  00:03
 Building cross-reference table 12 (search_engine)  [##############=     ] 73.68% 00:04
 Building cross-reference table 18 (server_response) [####################] 100.00%  00:05

Linux/UNIX

Follow the Mac OS X instructions, which are basically UNIX instructions (since Mac OS X is basically UNIX); change the directories to match the location where you installed Sawmill. The executable file usually ends with the version number on Linux/UNIX platforms, so you'll need to change references from "./sawmill" to "./sawmill-8.0.0" (or whatever the version is).

Additional Notes For All Platforms

When the command completes, the database will be built. If there is an error, it will be displayed in the command line window.

To get debugging output from the build (not usually useful), you can set the SAWMILL_DEBUG environment variable to 1, before rebuilding the database with the command above. On Windows, you can set this variable with "set SAWMILL_DEBUG=1". On Mac or other operating systems, you can run "export SAWMILL_DEBUG=1" (if you're using the bash shell), or "setenv SAWMILL_DEBUG 1" (if you're using csh). If you're not sure which shell you're running, type them both; one will work (it will not give any response), and one will give an error, which you can ignore.

You can also use the -v option to get "verbose" output from the build. There are many -v options available, documented in the "Command-line output types" page of the technical manual ( http://www.sawmill.net/cgi-bin/sawmill8/docs/sawmill.cgi?dp=docs.option&option_name=command_line.verbose ). For very high detail (too slow for any significant build), add "-v egblpfdD" to the command line. If you add much debugging output, you may also want to add "| more" to the end of the command line to pipe the output to a pager, or to add "> out.txt" to the end of the command line to redirect the output to a file.

For more examples of command-line usage, run Sawmill from the command line with the --help option.