2

I wrote a script with CGI and python, which accepts a folder path and then does some processing on the files inside.. The problem is this fails if the path is a network share mapped drive.. I read in many of the related queries that windows service doesnt allow this.

But they say if I use the UNC path then it should work, but it doesn't. because it has user authentication to undergo..

I found here something related but definitely it is not the solution I understand: How to copy files to network path or drive using Python

Can anyone help me somehow with this?? in the end the users of my script would be non-IT people so they would never understand the difference of the local drives and network drives, so this is kind of a requirement !

Community
  • 1
  • 1
asmicapri
  • 83
  • 6
  • Two questions: what is the exact error you are getting (I assume some kind of `WindowsError`? And does the script function correctly if you already have authenticated yourself for the remote folder? – jro Oct 25 '11 at 10:21
  • No even if the user is already authenticated.. it doesnt work **: [Error 5] Access is denied: '\\\\share\\folder\\' args = (5, 'Access is denied') errno = 13 filename = r'\\share\folder\' message = '' strerror = 'Access is denied' winerror = 5** – asmicapri Oct 25 '11 at 11:29
  • And you're sure the user you are running the script under has rights to write in that folder -- that is, can you write a file there via Windows Explorer? – jro Oct 25 '11 at 11:36
  • I don't have any other insights at the moment, so one last attempt: you say it is a CGI script you are running, and you mention a Windows service. Are you sure that the user _that is running the script_ has the correct rights to write to that network path? Note that this isn't necessarily the user you are currently working under, but might be some user only known to the local system. – jro Oct 25 '11 at 11:50
  • yes, i understand that.. that's what im fiddling around with, i have a local server and via a html page i call my cgi/python script which processes the files under the folder path provided in the html form (via a java applet). now say i have a network drive mapped as "X:\" then if the user (for now me, having the all access rights) provides a valid path like "X:\myfolder\allfiles\" then it complains "windowserror:The system cannot find the path specified" and if i give the UNC path, it says access denied.. I tried os.system("net use q: "path" "user" "pswrd"...) but this doesnt even work.. – asmicapri Oct 25 '11 at 14:27
  • The "net use" solution is supposed to work. Verify the command works from your account inside cmd.exe window. BTW, you don't have to specify drive letter to net use command. If you call it like `net use \\server\share /u:domain\username Password`, then you can use UNC path to access file share. This removes possible drive letter collision -- in case the drive letter is already used. – seva titov Oct 26 '11 at 01:38
  • thanks seva for the reply. I have checked from cmd and it works perfectly fine.. it also works on python independently, but doesnt work via the cgi browser code.. Any clue? – asmicapri Oct 26 '11 at 15:03

0 Answers0