sql-server - 在 SQL Server 中执行 bash 脚本
问题描述
我已经为 bash 编写了一个脚本,并在 Windows 10 上安装了 bash,因此当尝试在命令提示符下运行该脚本时,请编写以下语法:
bash -c "/home/behzad/SIP-CMD-BYE_OLT-CMD-ACT.sh 09400098129 1234 8 2
1 1 99 3 2001"
一切都好!现在我想在 SQL Server 中运行该脚本,为此在 SQL Server 中编写此 T-SQL:
EXEC master..xp_CMDShell 'bash -c "/home/behzad/SIP-CMD-BYE_OLT-CMD-ACT.sh 09400098129 1234 8 2 1 1 99 3 2001"'
但 SQL Server 只显示字符结果W
,而 bash 脚本不起作用。我该如何解决这个问题?谢谢大家。
解决方案
试试这个:
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO
推荐阅读
- ajax - 如何在 Laravel8 中从父类别中过滤子类别数据
- typescript - 带有 NestJS 的 Azure 存储 - 使用元数据保存和获取文件
- python - 检查 getattr 是否存在于 Python3 中的字典理解中
- javascript - 自动为所有 API 传递 api 密钥
- discord - 如何让它滚动多次
- git - 无法使用 shell 运行 gitlab runner
- ansible - 从 kolla-ansible 中删除以前部署的服务的正确方法是什么
- javascript - 如何编写来自 Google 表单上传的照片并将其大小设置为 1 英寸以在模板中显示?
- apache-spark - Spark 会话未初始化 | sparkR.session() 给出错误“if (len > 0) { 中的错误:参数长度为零”
- javascript - 如果存在特定元素,有没有办法为同一个变量分配不同的值?