I am trying to call a bash command through a user account with PsExec. Cygwin is being used, and I am trying to run a command from SQL:
我试图通过PsExec的用户帐户调用bash命令。正在使用Cygwin,我正在尝试从SQL运行命令:
exec master..xp_cmdshell 'psexec -u cyg_server -p <pwd> -accepteula "bash script.sh"';
However, I get the following error from psexec
:
但是,我从psexec得到以下错误:
Access is denied.
访问被拒绝。
PsExec could not start bash script.sh:
PsExec无法启动bash script.sh:
Any suggestions?
I am using SQL 2005, Windows Server 2008, and Cygwin with fresh binaries
我正在使用SQL 2005,Windows Server 2008和Cygwin以及新的二进制文件
1 个解决方案
#1
You're probably running this as a SQL user or a user without permissions to that file. My best bet is a SQL user (such as sa
). When you do this, the Windows credentials it uses are of the Service Account, which is SYSTEM
by default, but could be something else if you set it that way.
您可能以SQL用户或没有该文件权限的用户身份运行此操作。我最好的选择是SQL用户(例如sa)。执行此操作时,它使用的Windows凭据是服务帐户,默认情况下为SYSTEM,但如果您这样设置,则可能是其他内容。
If you're just calling this from within SQL, make sure that you are, in fact, running as a Windows user that has permissions to open all of the files necessary.
如果您只是在SQL中调用它,请确保您实际上是以具有打开所有必需文件的权限的Windows用户身份运行的。
If this is running in a SQL Server Agent job, you'll need to set up a Credential, and then set up a Proxy. Once you've done that, you can assign the Proxy to run the job (it's the third or fourth drop down on the Job Step dialog), and it will run with the correct Windows credentials.
如果这是在SQL Server代理作业中运行,则需要设置凭据,然后设置代理。完成后,您可以指定代理来运行作业(它是“作业步骤”对话框中的第三个或第四个下拉菜单),它将使用正确的Windows凭据运行。
#1
You're probably running this as a SQL user or a user without permissions to that file. My best bet is a SQL user (such as sa
). When you do this, the Windows credentials it uses are of the Service Account, which is SYSTEM
by default, but could be something else if you set it that way.
您可能以SQL用户或没有该文件权限的用户身份运行此操作。我最好的选择是SQL用户(例如sa)。执行此操作时,它使用的Windows凭据是服务帐户,默认情况下为SYSTEM,但如果您这样设置,则可能是其他内容。
If you're just calling this from within SQL, make sure that you are, in fact, running as a Windows user that has permissions to open all of the files necessary.
如果您只是在SQL中调用它,请确保您实际上是以具有打开所有必需文件的权限的Windows用户身份运行的。
If this is running in a SQL Server Agent job, you'll need to set up a Credential, and then set up a Proxy. Once you've done that, you can assign the Proxy to run the job (it's the third or fourth drop down on the Job Step dialog), and it will run with the correct Windows credentials.
如果这是在SQL Server代理作业中运行,则需要设置凭据,然后设置代理。完成后,您可以指定代理来运行作业(它是“作业步骤”对话框中的第三个或第四个下拉菜单),它将使用正确的Windows凭据运行。