LindbakRetail
asked on
xp_cmdshell returns null
xp_cmdshell returns null. I have turned on the security option for xp_cmdshell, so no error messages are thrown.
if i run:
exec master..xp_cmdshell 'blabla'
All i get is a recordset with one column and one row containing a null value.
It doesn't matter if i try to run a command text that should not work, like 'hello'. The result is still the same.
if i run:
exec master..xp_cmdshell 'blabla'
All i get is a recordset with one column and one row containing a null value.
It doesn't matter if i try to run a command text that should not work, like 'hello'. The result is still the same.
The only thing xp_cmdshell returns is 0 (success) or 1 (failure)
The xp_cmdshell is an external program to SQL Server. It spawns a command window and passes in a string for execution.
The xp_cmdshell is an external program to SQL Server. It spawns a command window and passes in a string for execution.
ASKER
No, the procedure results in a table containing the output from the command that i was passing. I.e. if I pass the string 'dir c:\' i would get a recordset with one column and with one row for each row of output from the command, in this case what dir outputs.
I run it on another Sql Server 2000 and 2005, and it works. But not on this particular server. What can be wrong?
I run it on another Sql Server 2000 and 2005, and it works. But not on this particular server. What can be wrong?
Are you running it manually, or have it scheduled as a job? If it is a job, does SQLAgent have the necessary permissions on that server?
ASKER
I'm running it as sa.
Do SA have the same permissions on that server as it does on the other servers? Because one server fails, that makes me believe it is probably a permissions issue.
On that server, is there anything in the application or system event logs?
On that server, is there anything in the application or system event logs?
ASKER
I found out that Panda Anti Virus was the problem. I disabled the component "TruePrevent" and I started to get some output!
Cool. It had to be something that made that server different than the others.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
DECLARE @result int
EXEC @result = xp_cmdshell 'your command'
IF (@result = 0)
PRINT 'Success'
ELSE
PRINT 'Failure'