views:

421

answers:

1

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:

exec master..xp_cmdshell 'psexec -u cyg_server -p <pwd> -accepteula "bash script.sh"';

However, I get the following error from psexec:

Access is denied.

PsExec could not start bash script.sh:

Any suggestions?

I am using SQL 2005, Windows Server 2008, and Cygwin with fresh binaries

+1  A: 

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.

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.

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.

Eric
Thank you Eric, I will try this. The script was indeed running as system.
ccook