Using system ESPs  xp_deletemail

Chapter 3: System Extended Stored Procedures

xp_cmdshell

Description

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

Syntax

xp_cmdshell command [, no_output ] [ return_status | no_wait ]

Parameters

command

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

no_output

if specified, suppresses any output from the command.

return_status

if specified, returns the completion status of the operating system command specified in the command parameter. If you do not use this parameter, the returned value is either 0 for success, or or 1 for failure, respectively.

no_wait

if specified, the xp_cmdshell operation immediately returns to the caller and the specified command executes as a background process. You see no output, and the returned result reflects only the success or failure of starting the command as a background process, not the success or failure of the process itself.

Examples

Example 1

On Windows – 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

On UNIX – Executes the operating system’s ls command and returns the list directory contents as a row of data:

xp_cmdshell 'ls'

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.





Copyright © 2005. Sybase Inc. All rights reserved. xp_deletemail

View this book as PDF