Finding
and Executing Command-Line Scripts
By default all scripts
are stored in the
following directory:
serverRoot/slapd-serverID
Be sure to refer to Command-Line Scripts Quick
Reference for the exact location of each script.
When scripts request either a directory name
or a file name, always provide the absolute path. The scripts assume
that you want to use the
dse.ldif file located in this directory:
serverRoot/slapd-serverID/config
|
|
Note
|
In order to
execute the Perl scripts, you must change to the directory where the
scripts are stored. Although it is possible to set command-path and
library-path variables to execute the scripts, it is not recommended
because you run the risk, particularly when you have more than one
server version installed, of disrupting the correct execution of other
utilities. There's also the risk of compromising the security of the
system.
(The same
procedure also applies to the
command-line utilities discussed in chapter 7, "Command-Line Utilities.")
Also, when you
are running
the Perl scripts on Windows machines, you must make sure that the path
environment variable contains the Perl executable (perl.exe)
file. For this reason, make sure to run the scripts from the
following directory on these machines:
serverRoot\bin\slapd\admin\bin
|
|
Shell
and Batch Scripts
This section covers the
following scripts:
Some of the shell and batch scripts can be
executed while the server is running. For others, the server must be
stopped. The description of each script below indicates whether the
server must be stopped or if it can continue to run while you execute
the script.
When a shell or batch script has a Perl
equivalent, there is a cross-reference to the section describing the
equivalent Perl script.
|
|
Note
|
When using the batch scripts on Windows, the
-s
option may not function correctly because of a bug in the Windows
command-line interpreter. The command-line interpreter removes the
double quotes and treats values as separate in some cases.
|
|
bak2db
(Restore database from backup)
Restores the database
from the most recent
archived backup. To run this script, the server must be stopped.
db2bak (Create backup of database)
Creates a backup of the
current database
contents. This script can be executed while the server is still running.
Syntax
|
Shell script
(UNIX):
|
db2bak [backupDirectory]
|
|
Batch file
(Windows):
|
db2bak [backupDirectory]
|
For information on the equivalent Perl
script, refer to db2bak.pl
(Create backup of database).
db2ldif (Export database
contents to LDIF)
Exports the contents of
the database to LDIF.
This script can be executed while the server is still running.
For information on the equivalent Perl
script, see db2ldif.pl
(Export database contents to LDIF).
For the shell and batch scripts, the script
runs the
slapd (Windows) or
ns-slapd (UNIX) command-line utility with the
ldif2db keyword.
Syntax
|
Shell script
(UNIX):
|
db2ldif {-n
backendInstance}* | {-s includeSuffix}* [{-x excludeSuffix}*] [-r] [-C] [-u]
[-U] [-m] [M] [-a outputFile] [-1] [-N] [-E]
|
|
Batch file
(Windows):
|
db2ldif {-n
backendInstance}* | {-s includeSuffix}* [{-x excludeSuffix}*] [-r] [-C] [-u]
[-U] [-m] [M] [-a outputFile] [-1] [-N] [-E]
|
Options
You must specify either
the
-n or the
-s option. By default, the output LDIF will be stored in one
file.
Should you want to specify the use of several files, then use the
option
-M.
|
Option
|
Parameter
|
Description
|
|
-a
|
outputFile
|
Name of the output
LDIF file.
|
|
-n
|
backendInstance
|
Instance to be
exported.
|
|
-s
|
includeSuffix
|
Suffixes to be
included or the subtrees to be included if
-n has been used.
|
|
-x
|
excludeSuffix
|
Suffixes to be
excluded.
|
|
-r
|
|
Export replica.
|
|
-C
|
|
Only the main db
file is used.
|
|
-u
|
|
Request that the
unique id is not exported.
|
|
-U
|
|
Request that the
output LDIF is not folded.
|
|
-m
|
|
Minimal base-64
encoding.
|
|
-M
|
|
Use of several
files for storing the output LDIF, with each instance stored in
instance filename (where filename is the filename specified for
-a option).
|
|
-1
|
|
Delete, for
reasons of backward compatibility, the first line of the LDIF file
which gives the version of the LDIF standard.
|
|
-N
|
|
Specifies that the
entry IDs are not to be included in the LDIF output. The entry IDs are
necessary only if the
db2ldif output is to be used as input to
db2index.
|
-E
|
|
Decrypts encrypted data during
export. This
option is used only if database encryption is enabled.
|
db2dsml
(Export database contents to DSML)
Exports the contents
of the database to DSML version 1.0. This
script can be executed while the server is still running.
Syntax
|
Shell script
(UNIX):
|
db2dsml {-n
backendInstance}* | {-s includeSuffix}* [{-x excludeSuffix}*] [-u] [-a
outputFile]
|
|
Batch file
(Windows):
|
db2dsml {-n
backendInstance}* | {-s includeSuffix}* [{-x excludeSuffix}*] [-u] [-a
outputFile]
|
Options
You must specify either
the
-n or
-s option.
|
Option
|
Parameter
|
Description
|
|
-n
|
backendInstance
|
Instance to be
exported.
|
|
-s
|
includeSuffix
|
Suffixes to be
included or to specify the subtrees to be included if
-n has been used.
|
|
-x
|
excludeSuffix
|
Suffixes to be
excluded.
|
|
-u
|
|
Request that the
the unique ID be not exported.
|
|
-a
|
outputFile
|
Name of the output
DSML file.
|
db2index (Reindex database
index files)
Reindexes the database
index files.
For information on the equivalent Perl
script, see db2index.pl
(Create and generate indexes).
Syntax
|
Shell script
(UNIX):
|
db2index [-n
backendInstance | {-s includeSuffix}* -t attributeName -T vlvAttribute]
|
|
Batch file
(Windows):
|
db2index [-n
backend_instance | {-s includeSuffix}* -t attributeName -T
vlvAttribute]
|
Usage
Here are a few sample
commands:
- To reindex all the
database index files:
$ db2index
- To reindex cn and givenname
in the database instance userRoot:
$ db2index -n
userRoot -t cn -t givenname
- To reindex cn in the
database where the root suffix is dc=example,dc=com:
$ db2index -s
"dc=example,dc=com" -t cn
Options
|
Option
|
Parameter
|
Description
|
|
-n
|
backendInstance
|
Instance to be
reindexed.
|
|
-s
|
includeSuffix
|
Suffixes to be
included or the subtrees to be included if
-n has been used.
|
|
-t
|
attributeName
|
Name(s) of the
attributes to be reindexed.
|
|
-T
|
vlvAttribute
|
Name(s) of the VLV
attributes to be reindexed.
|
dsml2db
(Import DSML document contents into database)
Imports the contents
of the DSML version 1.0 document into the
database. To run this script, the server must be stopped.
Syntax
|
Shell script
(UNIX):
|
dsml2db -n
backendInstance | {-s includeSuffix}* [{-x excludeSuffix}*] {-i dsmlFile}
|
|
Batch file
(Windows):
|
dsml2db -n
backendInstance | {-s includeSuffix}* [{-x excludeSuffix}*] {-i dsmlFile}
|
Options
|
Option
|
Parameter
|
Description
|
|
-n
|
backendInstance
|
Instance to be
exported.
|
|
-s
|
includeSuffix
|
Suffix(es) to be
included or to specify the subtree(s) to be included if
-n has been used.
|
|
-x
|
excludeSuffix
|
Suffix(es) to be
excluded.
|
|
-i
|
dsmlFile
|
Name of the input
DSML file.
|
getpwenc (Print encrypted password)
Prints the encrypted
form of a password using
one of the server's encryption algorithms. If a user cannot log in, you
can use this script to compare the user's password to the password
stored in the directory.
Syntax
|
Shell script
(UNIX):
|
getpwenc storagescheme
clearpassword
|
|
Batch file
(Windows):
|
getpwenc storageScheme
clearpassword
|
ldif2db (Import)
Runs the
slapd (Windows) or
ns-slapd (Unix) command-line utility with the
ldif2db keyword. To run this script, the server must be stopped.
For information on the equivalent Perl
script, refer to ldif2db.pl
(Import).
|
|
Note
|
ldif2db
supports LDIF version 1 specifications. You can load an
attribute using the
:< URL specifier notation; for example:
jpegphoto:<
file:///tmp/myphoto.jpg
Although the
official notation requires
three
///, the use of one
/ is tolerated. For further information on the LDIF format, see
chapter 4, "Managing Directory Entries," in the Netscape Directory
Server Administrator's Guide.
|
|
Syntax
|
Shell script
(UNIX):
|
ldif2db -n
backendInstance | {-s includeSuffix}* [{-x excludeSuffix}*] {-i ldifFile}* [-O] [-g string] [-G namespaceId] [-E]
|
|
Batch file
(Windows):
|
ldif2db -n
backendInstance | {-s includeSuffix}* [{-x excludeSuffix}*] {-i ldifFile}* [-O] [-g string] [-G namespaceId] [-E]
|
Options
|
Option
|
Parameter
|
Description
|
|
-n
|
backendInstance
|
Instance to be
imported. Ensure that you specify an instance that corresponds to the
suffix contained by the LDIF file because, otherwise, the data
contained by the database is deleted, and the import fails.
|
|
-s
|
includeSuffix
|
Suffixes to be
included or to specify the subtrees to be included if
-n has been used.
|
|
-x
|
excludeSuffix
|
Suffixes to be
excluded.
|
|
-i
|
ldifFile
|
Names of the input
LDIF files. When you import multiple files, they are imported in the
order in which you specify them on the command-line.
|
|
-O
|
|
Request that only
the core db is created without attribute indexes.
|
|
-g
|
string
|
Generation of a
unique ID. Type
none for no unique ID to be generated and
deterministic for the generated unique ID to be name-based. By
default, a time based unique ID is generated.
If you use the
deterministic generation to have a name-based unique ID, you can
also specify the namespace you want the server to use as follows:
-g deterministic namespace_id
where
namespace_id is a string of characters in the following format
00-xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx
Use this option
if you want to import
the same LDIF file into two different Directory Servers and you want
the contents of both directories to have the same set of unique IDs. If
unique IDs already exist in the LDIF file you are importing, then the
existing IDs are imported to the server, regardless of the options you
have specified.
|
|
-G
|
namespaceId
|
Generates a
namespace ID as a name-based unique ID. This is the same as specifying
the
-g deterministic
option.
|
|
-c
|
|
Merge chunk size.
|
-E
|
|
Encrypts data during import.
This option is used only if database encryption is
enabled.
|
ldif2ldap (Perform import operation over LDAP)
Performs an import
operation over LDAP to the
Directory Server. To run this script, the server must be running.
Syntax
|
Shell script
(UNIX):
|
ldif2ldap -D
rootdn -w password -f filename
|
|
Batch file
(Windows):
|
ldif2ldap -D
rootdn -w password -f filename
|
Options
|
Option
|
Parameter
|
Description
|
|
-D
|
rootdn
|
User DN with root
permissions, such as Directory Manager.
|
|
-w
|
password
|
Password
associated with the user DN.
|
|
-f
|
filename
|
Name of the file
to be imported. When you import multiple files, they are imported in
the order in which you specify them on the command-line.
|
monitor (Retrieve monitoring information)
Retrieves performance
monitoring information
using the
ldapsearch command-line utility.
Syntax
|
Shell script
(UNIX):
|
monitor
|
|
Batch file
(Windows):
|
monitor
|
Options
There are no options for
this script.
For more information on the
ldapsearch command-line utility, see section ldif in chapter 7.
restart-slapd
(Restart the Directory Server)
Restarts the Directory
Server.
Syntax
|
Shell script
(UNIX):
|
restart-slapd
|
|
Batch file
(Windows):
|
restart-slapd
|
Options
There are no options for
this script.
Exit Status
|
0
|
Server restarted
successfully.
|
|
1
|
Server could not
be started.
|
|
2
|
Server restarted
successfully but was already stopped.
|
|
3
|
Server could not
be stopped.
|
restoreconfig
(Restore Administration Server
Configuration)
Restores, by default,
the most recently saved
Administration Server configuration information to the
NetscapeRoot partition under the following directory:
serverRoot/slapd-serverID/config
To restore the Administration Server
configuration:
- Stop the Directory Server.
- Run the restoreconfig
script.
- Restart the Directory
Server.
- Restart the
Administration Server for the
changes to be taken into account.
Syntax
|
Shell script
(UNIX):
|
restoreconfig
|
|
Batch file
(Windows):
|
restoreconfig
|
Options
There are no options for
this script.
saveconfig
(Save Administration Server Configuration)
Saves Administration
Server configuration
information to the following directory:
serverRoot/slapd-serverID/confbak
This script will only run if the
server is running.
Syntax
|
Shell script
(UNIX):
|
saveconfig
|
|
Batch file
(Windows):
|
saveconfig
|
Options
There are no options for
this script.
start-slapd (Start the Directory Server)
Starts the Directory
Server. It might be a
good idea to check whether the server has been effectively started
using the
ps command because it could sometimes be that the script
returned
while the startup process was still on-going, resulting in a confusing
message.
Syntax
|
Shell script
(UNIX):
|
start-slapd
|
|
Batch file
(Windows):
|
start-slapd
|
Options
There are no options for
this script.
Exit Status
|
0
|
Server started
successfully.
|
|
1
|
Server could not
be started.
|
|
2
|
Server was already
started.
|
stop-slapd (Stop the Directory Server)
Stops the Directory
Server. It might be a
good idea to check whether the server has been effectively stopped
using the
ps command because it could sometimes be that the script
returned
while the shutdown process was still on-going, resulting in a confusing
message.
Syntax
|
Shell script
(UNIX):
|
stop-slapd
|
|
Batch file
(Windows):
|
stop-slapd
|
Options
There are no options for
this script.
Exit Status
|
0
|
Server stopped
successfully.
|
|
1
|
Server could not
be stopped.
|
|
2
|
Server was already
stopped.
|
suffix2instance
(Map suffix to backend name)
Maps a suffix to a
backend name.
Syntax
|
Shell script
(UNIX):
|
suffix2instance
{-s suffix}
|
|
Batch file
(Windows):
|
suffix2instance
{-s suffix}
|
Options
|
-s
|
Suffix to be
mapped to the backend.
|
vlvindex (Create virtual list view indexes)
To run the
vlvindex script, the server must be stopped. The
vlvindex script creates virtual list view (VLV) indexes, known
in
the Directory Server Console as browsing
indexes. VLV indexes introduce flexibility in the way you view search
results. Using VLV indexes, you can organize search results
alphabetically or in reverse alphabetical order, and you can scroll
through the list of results. VLV index configuration must already exist
prior to running this script.
Syntax
|
Shell script
(UNIX):
|
vlvindex [-d
debugLevel] [-n backendInstance] [-s suffix [-T vlvTag]
|
|
Batch file
(Windows):
|
vlvindex [-d
debugLevel] -n backendInstance [-s suffix [-T vlvTag]
|
Options
You must specify either
the
-n or the
-s option.
|
Option
|
Parameter
|
Description
|
|
-d
|
debugLevel
|
Specifies the
debug level to use during index creation. Debug levels are defined in nsslapd-errorlog-level (Error
Log Level).
|
|
-D
|
|
Specifies the
server configuration directory that contains the configuration
information for the index creation process. You must specify the full
path to the
slapd-serverID directory.
|
|
-n
|
backendInstance
|
Name of the
database containing the entries to index.
|
|
-s
|
suffix
|
Name of the suffix
containing the entries to index.
|
|
-T
|
vlvTag
|
VLV index
identifier to use to create VLV indexes. You can use the console to
specify VLV index identifier for each database supporting your
directory tree, as described in the
NNetscape Directory
Server Administrator's Guide. You can define
additional VLV tags by creating them in LDIF and
adding them to Directory Server's configuration, as described in the Netscape Directory
Server Administrator's Guide. In any case, we
recommend you use the DN of the entry for which you
want to accelerate the search sorting.
|
Perl Scripts
This section covers the
following scripts:
|
|
Note
|
The Perl scripts
that are bundled with Directory Server require the use of
nsPerl, which is included in the
serverRoot/bin/slapd/admin/bin
directory.
Be sure to change to this directory before you run any of the Perl
scripts:
cd serverRoot/bin/slapd/admin/bin
./perl
PerlScriptName
Arguments
|
|
bak2db.pl
(Restore database from backup)
Restores a database from
a backup.
Syntax
|
Perl script (UNIX
and Windows):
|
bak2db.pl [-v] -D
rootdn -w password [-a backupDirectory] [-t databaseType]
|
Options
The script
bak2db.pl creates an entry in the directory that launches this
dynamic task. The entry is generated based upon the values you provide
for each option.
|
Option
|
Parameter
|
Description
|
|
-D
|
rootdn
|
The user DN with
root permissions, such as
Directory Manager. The default is the DN of the Directory
Manager, which is read from
the
nsslapd-root attribute under
cn=config.
|
|
-w
|
password
|
The password
associated with the user DN.
|
|
-a
|
backupDirectory
|
The directory of
the backup files.
|
|
-v
|
|
Verbose mode.
|
|
-t
|
databaseType
|
The database type.
Currently, the only possible database type is
ldbm.
|
db2bak.pl
(Create backup of database)
Creates a backup of the
database.
Syntax
|
Perl script (UNIX
and Windows):
|
db2bak.pl [-v] -D
rootdn -w password [-a dirName]
|
Options
The script
db2bak.pl creates an entry in the directory that launches this
dynamic task. The entry is generated based upon the values you provide
for each option. Currently, the only possible database type is
ldbm.
|
Option
|
Parameter
|
Description
|
|
-D
|
rootdn
|
The user DN with
root permissions, such as
Directory Manager. The default is the DN of the Directory
Manager, which is read from
the
nsslapd-root attribute under
cn=config.
|
|
-w
|
password
|
The password
associated with the user DN.
|
|
-a
|
dirName
|
The directory
where the backup files will be stored. By default it is under
serverRoot/slapd-serverID/bak
The backup file
is named according to
the year-month-day-hour format (YYYY_MM_DD_hhmmss).
|
|
-v
|
|
Verbose mode.
|
|
-t
|
|
The database type.
Currently, the only possible database type is
ldbm.
|
db2index.pl (Create and generate indexes)
Creates and generates
the new set of indexes
to be maintained following the modification of indexing entries in the
cn=config configuration file.
Syntax
|
Perl script (UNIX
and Windows):
|
db2index.pl [-v]
-D rootdn { -w password | -j filename} [-n backendInstance] [-t attributeName]
|
Options
The script
db2index.pl creates an entry in the directory that launches this
dynamic task. The entry is generated based upon the values you provide
for each option.
|
Option
|
Parameter
|
Description
|
|
-v
|
|
Verbose mode.
|
|
-D
|
rootdn
|
The user DN with
root permissions, such as
Directory Manager.
|
|
-w
|
password
|
The password
associated with the user DN.
|
|
-n
|
backendInstance
|
The instance to be
indexed. If the instance is not specified, the script reindexes all
instances.
|
|
-t
|
attributeName
|
The name of the
attribute to be indexed. If omitted, all the indexes defined for the
specified instance are generated.
|
|
-j
|
filename
|
The name of the
file containing the password.
|
db2ldif.pl (Export database contents to LDIF)
Exports the contents of
the database to LDIF.
This script creates an entry in the directory that launches this
dynamic task. The entry is generated based upon the values you provide
for each option. The
*
indicates that multiple occurrences are allowed.
Syntax
|
Perl script (UNIX
and Windows):
|
db2ldif.pl [-v] -D
rootdn -w password {-n backendInstance}* | {-s includeSuffix}* [{-x excludeSuffix}*] [-a outputFile] [-N] [-r] [-C]
[-u] [-U] [-m] [-o]
[-1] [M]
|
Options
To run this script, the
server must be
running, and either
-n
backend_instance or
-s
includesuffix is required.
This Perl script
db2ldif.pl creates an entry in the directory that launches this
dynamic task. The entry is generated based upon the values you provide
for each option.
|
Option
|
Parameter
|
Description
|
|
-v
|
|
Verbose mode.
|
|
-D
|
rootdn
|
The user DN with
root permissions, such as
Directory Manager.
|
|
-w
|
password
|
The password
associated with the user DN.
|
|
-n
|
|