xp_cmdshell

Description

Executes a native operating system command on the host system running Adaptive Server.

Syntax

xp_cmdshell command [, no_output]

Parameters

command

is the operating system command string; maximum length is 255 bytes.

no_output

if specified, suppresses any output from the command.

Examples

Example 1

Silently copies the file named log on the C drive to a file named log.0102 on the A drive:

xp_cmdshell 'copy C:\log A:\log.0102', no_output

Example 2

Executes the operating system’s date command and returns the current date as a row of data:

xp_cmdshell 'date'

Usage

Permissions

By default, only a System Administrator can execute xp_cmdshell. A System Administrator can grant execute permission to other users.

See also

See the System Administration Guide for more information about xp_cmdshell context.