Carries out an operating system command from a procedure.
xp_cmdshell( command [ , 'no_output' ] )
command Use this CHAR(8000) parameter to specify a system command.
'no_output' Use this optional CHAR(254) parameter to specify whether to display output. The default behavior is to display output. If this parameter is the string 'no_output', no output is displayed.
xp_cmdshell executes a system command and then returns control to the calling environment. The value returned by xp_cmdshell is the exit code from the executed shell process. The return value is 2 if an error occurs when the child process is started.
The second parameter affects only command line applications on Windows operating systems. For Unix, no output appears, regardless of the setting for the second parameter.
For Windows Mobile, any commands executed are visible in the database server message log, regardless of the setting for the second parameter. The console shell \\windows\cmd.exe is needed to run the procedure.
DBA authority required
The following statement lists the files in the current directory in the file c:\temp.txt:
xp_cmdshell( 'dir > c:\\temp.txt' ) |
The following statement carries out the same operation, but does so without displaying a Command window.
xp_cmdshell( 'dir > c:\\temp.txt', 'no_output' ) |
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |