[ismael] | My objective is check if some directories exist and if the | user that execute the perl script has access to some files | and directories. If one of this checkpoints failed the | execution will be aborted. If all of then finish ok | the execution will continue. It's simply this.
I think you've got two options: 1) Invest some time in understanding the Win32 security model -- which is quite a bit more complex than the (default) Posix model. You'll need to use the win32security module or some ctypes code and see if the logged-on user has the necessary permissions on the file of your choice. or 2) Do it anyway, wrap it in a try-except block and catch the OSError exception (or whatever exception it is). That could be for several reasons, but I suspect that you don't really care *why* this user can't execute, merely that he can't. NB This appraoch is generally well-regarded under Python. In theory between the time you check the permissions and the execution of the script something could happen which changes the situation. If you simply trap any exceptions, you'll always be timely. <code - a but crude and entirely untested> import os path_i_cant_access = r"\\vogbs022\it\canadasp" try: result = os.listdir (path_i_cant_access) except OSError: print "Couldn't read, or something else happened" else: print "The result was", result </code> Hope that helps TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ -- http://mail.python.org/mailman/listinfo/python-list