Results 1 to 2 of 2

Thread: Xp_cmdshell & xp_fileexists

  1. #1
    Kevin Guest

    Xp_cmdshell & xp_fileexists


    When I type exec master..xp_cmdshell 'dir *.* 'E:ABCEFG'
    it shows the list of file and directorys(that's fine)

    BUT if I type
    master..xp_fileexist 'E:ABCEFGmydoc.txt'
    it tells me:

    File Exists File is a Directory Parent Directory Exists
    ----------- ------------------- -----------------------
    0 0 0

    When I know the file exists, and it shows up when using the first
    command. Why, is it saying it dosen't exists?
    the folder is a shared folder.

  2. #2
    Juergen Leis Guest

    Xp_cmdshell & xp_fileexists (reply)

    1)
    If you run >EXEC master..xp_cmdshell &#39;dir *.* E:ABCEFG&#39;<
    it shows you the contents of the current working drive
    and directory on your server (check directory name in output)
    you should run >EXEC master..xp_cmdshell &#39;dir E:ABCEFG*.*&#39;

    2)
    I suppose you didn&#39;t give the real directory names and that your
    directory names contain spaces or special characters.
    In this case you must surround the path name in the dir command with
    double quotes (&#34
    e.g.:
    EXEC master..xp_cmdshell &#39;dir &#34;C:Program FilesWindows NT*.*&#34;&#39;
    if you then run
    EXEC master..xp_fileexist &#39;&#34;C:Program FilesWindows NThypertrm.exe&#34;&#39;
    it will not find the file, because the double qutes
    are interreted as part of the name and results in

    File Exists File is a Directory Parent Directory Exists
    ----------- ------------------- -----------------------
    0 0 0

    (1 row(s) affected)

    instead you should run
    EXEC master..xp_fileexist &#39;C:Program FilesWindows NThypertrm.exe&#39;
    which indicates that the file exists:

    File Exists File is a Directory Parent Directory Exists
    ----------- ------------------- -----------------------
    1 0 1

    (1 row(s) affected)






    ------------
    Kevin at 1/9/2002 3:00:08 PM


    When I type exec master..xp_cmdshell &#39;dir *.* &#39;E:ABCEFG&#39;
    it shows the list of file and directorys(that&#39;s fine)

    BUT if I type
    master..xp_fileexist &#39;E:ABCEFGmydoc.txt&#39;
    it tells me:

    File Exists File is a Directory Parent Directory Exists
    ----------- ------------------- -----------------------
    0 0 0

    When I know the file exists, and it shows up when using the first
    command. Why, is it saying it dosen&#39;t exists?
    the folder is a shared folder.

Posting Permissions

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