?
Solved

xp_cmdshell 'dir G:\' don't show all subdir' in directory

Posted on 2003-02-24
5
Medium Priority
?
978 Views
Last Modified: 2011-10-03
I'm trying to validata file existance in a local directory in my computer. I'm executing this procedure through Sql Analizer and this is the exact syntax:
exec xp_cmdshell 'dir G:\'
The output shows only 1 subdirectory but not the others.
When i'm typing the same command through dos, it works fine and shows all the directories.
The operating system is win2k, sql server is standard edition.
Thanks in advance,
Ofer
0
Comment
Question by:ofergold
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Expert Comment

by:Divaqs
ID: 8011921
Hi ofergold,

What Windows permissions are the SQL server executing under? I would suggest checking.
0
 

Expert Comment

by:mohit108
ID: 8014295
Hi ofergold

U should sheck the windows permission using which u have logged on to the SQL Server.

xp_cmdshell is even more confusing with "Network Mapped Drives" if G: is ur network drive then it won't give u the desired result.

I have tried "xp_cmdshell 'dir/p N:'", it will give u
The system cannot find the path specified.
but the same command from DOS will give u all the directories (dir/p N:)

Thanks
0
 
LVL 1

Accepted Solution

by:
KatanaCS earned 100 total points
ID: 8021222
When using xp_cmdshell, the network account being used is listed in the "Service StartUp Account" of the SQL Server Agent properties.  If this account is different than your account (which is rather normal), then any permissions and network mappings that you have are not carried over into xp_cmdshell.

For example:
  You have "G:\" mapped to "\\Myserver\", which has subdirectories "\DirA", "\DirB", and "\DirC".  It's entirely possible that the SQLAgent account only has permissions to "\DirC" and not the others, or even that it's "G:\" drive is mapped to "\\MyOTHERServer", which only has "\DirC" as a subdirectory.

Regards,
KatanaCS
0
 

Expert Comment

by:CleanupPing
ID: 9276381
ofergold:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 

Author Comment

by:ofergold
ID: 9283319
Please remove question
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question