Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (中文) » SQL Anywhere 服务器 - SQL 参考 » 系统对象 » 系统过程 » 按字母顺排序的系统过程列表

 

xp_cmdshell 系统过程

从过程中执行操作系统命令。

语法
xp_cmdshell( 
command 
[ , 'no_output' ] )
参数
  • command   使用此 CHAR(8000) 参数指定一个系统命令。

  • 'no_output'   使用此可选的 CHAR(254) 参数指定是否显示输出。缺省行为是显示输出。如果此参数为字符串 'no_output',则不显示输出。

注释

xp_cmdshell 执行系统命令,然后将控制返回给调用环境。由 xp_cmdshell 返回的值是所执行的 shell 进程的退出代码。如果在开始子进程时发生错误,返回值为 2。

第二个参数只影响 Windows 操作系统上的命令行应用程序。对于 Unix,无论如何设置第二个参数,都不显示任何输出。

但对于 Windows Mobile,无论如何设置第二个参数,执行的任何命令都会在数据库服务器消息日志中显示。运行该过程时需要控制台 shell \\windows\cmd.exe

权限

需要 DBA 权限

另请参见
示例

以下语句列出文件 c:\temp.txt 中当前目录下的文件:

xp_cmdshell( 'dir > c:\\temp.txt' )

以下语句执行相同的操作,但在执行时不显示 [命令] 窗口。

xp_cmdshell( 'dir > c:\\temp.txt', 'no_output' )