Results 1 to 11 of 11
  1. #1
    Join Date
    Jul 2008
    Posts
    3

    Unanswered: Problem with xp_cmdshell

    Hello
    I am developing a software and i am using xp_cmdshell stored procedure.It was working perfectly for 2 days i was seeing usual output in my software but now this command returns null value immediately.Does anybody has any idea why this command started to return null value?

    Thank you in advance.
    Kivanc

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    my psychic powers are a little weaker in my old age. is there a scenario where whatever it is you are using xp_cmdshell for does not return something or will not execute?
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Jul 2008
    Posts
    3

    key point is,I was getting an output yesterday.command is something like this.
    EXEC master.dbo.xp_cmdshell 'type c:/a.txt'
    software is processing this output.
    there is no output for 'dir' either. I only see Null.
    Sql server version is 2000.I hope this informations can help you.
    Best Regards

  4. #4
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    the point is, I doubt xp_cmdshell is your problem.

    What happens when you remove that from the equation and you just issue the same from DOS prompt?
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  5. #5
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696
    Quote Originally Posted by kivancimer

    key point is,I was getting an output yesterday.command is something like this.
    EXEC master.dbo.xp_cmdshell 'type c:/a.txt'
    software is processing this output.
    there is no output for 'dir' either. I only see Null.
    Sql server version is 2000.I hope this informations can help you.
    Best Regards
    Should be 'type c:\a.txt' not 'type c:/a.txt', not sure if this is your problem.

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    I think that is exactly why one should always post precisely what is executed, not "it was something like this:". I helped blindman debug about a hundred lines of VBA code a couple of years ago. The error was a single fullstop (period to you Americans). If he had posted code that was "something like it" we would never have sorted it out. The point is: even buried in 100 lines, a "." is too far removed from the correct code for a computer.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  7. #7
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    First of all, can I say that using xp_cmdshell is a truly bad idea? This means the application you are creating has access to a command line on your SQL Server. Does anything else scream "hacker gold" more than that?

  8. #8
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    i pointed out that and the fact that there so many sysadmin accounts in production here and I got silence over the phone. some people need to get burned by the stove before tey know it is hot.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  9. #9
    Join Date
    Jul 2008
    Posts
    3
    Thanks for the answers.But i think i need be be more clear about the issue.
    To keep it simple:
    When i connected to sql server via SQL Server Management Studio Express
    and make a new query like "EXEC master.dbo.xp_cmdshell 'dir' " There were some results.But now i can see only "NULL".When i connect to database remotely and execute dir on command prompt,everything is normal.
    When i try to execute same query on sql server via sql query analyzer i see the same result "NULL".

    @ MCrowley: Yes You are right about security issue.I will think of an alternative but this is a small company and i dont't think there could be any problem.

    Thanks

  10. #10
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by kivancimer
    @ MCrowley: Yes You are right about security issue.I will think of an alternative but this is a small company and i dont't think there could be any problem.
    Willing to bet your job on it?
    George
    Home | Blog

  11. #11
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Could be many things, including the fact that a.TXT is empty, but based on statistics over the years it deals with something that has changed in your environment, possibly related to file system permissions.
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •