Using Exec master..xp_cmdshell @variable

  • I am trying to run a command through the command line but I keep getting an error:

    'Run-Time error 76: Path not found'

    Here is what I am passing into the command line:

    g:\cnd_reports\JmailAirCND.exe BKSF05-145 5/9/2005 104445

    I have confirmed with my programmer that this (BFSF05-145 5/9/2005 104445) is exactly what he wants passed into the executable(JmailAirCND.exe).

    I am not running this locally on the server but rather I am connecting through Remote Desktop for testing purposes, not sure if this affects the result or not....just wanted to throw it in.

    If someone could please help, then it would be greatly appreciated. Thanks in advance!

  • How (where) is the G: drive mapped on the server for the user ID that SQL Server runs under?

    TRY: EXEC master..xp_cmdshell "DIR G:\" 

    or similar to find out. 

  • Cory, use the UNC path to the executable when using xp_cmdshell to avoid conflicts with different drive mappings.

    dab

  • I agree that UNC's are the way to go to avoid potential conflicts. You also might want to check security. In other words do the service accounts have access to the computer/directory/files that you are trying execute etc...

    RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."

  • The G drive is local to the machine and these are the results when I ran:

    EXEC master..xp_cmdshell "DIR G:\"

     Volume in drive G is DATA

     Volume Serial Number is 5010-1ECA

    NULL

     Directory of G:

    NULL

    03/31/2005  05:14 PM    <DIR>          bak

    05/02/2005  05:26 PM    <DIR>          DataFiles

    02/16/2005  10:46 AM    <DIR>          DFO

    05/09/2005  04:27 PM    <DIR>          dnd_reports

    03/11/2005  03:17 PM    <DIR>          FTPServer

    02/03/2005  05:50 PM    <DIR>          photo_scratch

    05/11/2005  09:15 AM    <DIR>          SISPHOTOS

    04/01/2005  09:54 AM    <DIR>          Software

    02/15/2005  10:10 AM    <DIR>          sp3

    02/15/2005  10:58 AM    <DIR>          sql_bu

    02/04/2005  10:23 AM    <DIR>          sql_data

    02/03/2005  02:23 PM    <DIR>          WUTemp

                   0 File(s)              0 bytes

                  12 Dir(s)  345,716,072,448 bytes free

    NULL

  • how about:

    exec xp_cmdshell 'DIR g:\cnd_reports\JmailAirCND.exe'

    and

    exec xp_cmdshell 'DIR \\server_name\share_name\cnd_reports\JmailAirCND.exe'

    RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."

  • 03/31/2005  05:14 PM    <DIR>          bak

    05/02/2005  05:26 PM    <DIR>          DataFiles

    02/16/2005  10:46 AM    <DIR>          DFO

    05/09/2005  04:27 PM    <DIR>          dnd_reports

    03/11/2005  03:17 PM    <DIR>          FTPServer

    02/03/2005  05:50 PM    <DIR>          photo_scratch

    05/11/2005  09:15 AM    <DIR>          SISPHOTOS

    04/01/2005  09:54 AM    <DIR>          Software

    02/15/2005  10:10 AM    <DIR>          sp3

    02/15/2005  10:58 AM    <DIR>          sql_bu

    02/04/2005  10:23 AM    <DIR>          sql_data

    02/03/2005  02:23 PM    <DIR>          WUTemp

    exec xp_cmdshell 'g:\dnd_re~1\JmailAirCND.exe BKSF05-145 5/9/2005 104445'

    exec xp_cmdshell 'g:\dnd_reports\JmailAirCND.exe BKSF05-145 5/9/2005 104445'

    mispelled??? cnd_reports = dnd_reports

  • Sorry about the mispelling in the previous post. None of the above seems to be working. It does work from the command line though:

    G:\cnd_reports\JmailAirCND.exe BKSF05-145 5/9/2005 104445

    Could this be a permissions issue? Under which the SQL Service Manager is running?

    I am running this script on Windows Server 2003 SP1 and SQL Server 2000 SP3.

    I tried using the UNC paths and those examples given above but nothing seems to be working.

    Any further help would be greatly appreciated.

  • It could definitley be a permissions issue. To determine the account used by SQL Server go to services, double click MSSQL service and click the "Logon tab". Then, try logging into the remote server using the account under which sql server is running.

    dab

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply