Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Checking File permissions

Reply
Thread Tools

Checking File permissions

 
 
Anoop
Guest
Posts: n/a
 
      07-20-2006
Hi All

Please tell me how to check the existence of a file and the read
permission to the file using python script

Thanks for ur inputs

Anoop

 
Reply With Quote
 
 
 
 
Avell Diroll
Guest
Posts: n/a
 
      07-20-2006
Anoop wrote:
> Please tell me how to check the existence of a file and the read
> permission to the file using python script


You can check the os module (os.stat comes to mind).

For an exemple you can have a look at :
http://www.pixelbeat.org/talks/python/ls.py

Regards,

Avell
 
Reply With Quote
 
 
 
 
Tal Einat
Guest
Posts: n/a
 
      07-21-2006

Anoop wrote:
> Hi All
>
> Please tell me how to check the existence of a file and the read
> permission to the file using python script
>
> Thanks for ur inputs
>
> Anoop


os.access(path, mode) does just this, check it out.

Cross-platform-ness isn't a problem, the docs say it is available for
Windows, Unix and Mac, and I've used it without a hitch on Win2k, WinXP
and various Linux and Unix platforms.

>>> help(os.access)

Help on built-in function access in module nt:

access(...)
access(path, mode) -> 1 if granted, 0 otherwise

Use the real uid/gid to test for access to a path. Note that most
operations will use the effective uid/gid, therefore this routine
can
be used in a suid/sgid environment to test if the invoking user has
the
specified access to the path. The mode argument can be F_OK to
test
existence, or the inclusive-OR of R_OK, W_OK, and X_OK.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking File permissions Anoop Python 1 07-21-2006 05:26 AM
Checking File permissions Anoop Python 1 07-20-2006 02:11 PM
ASPX file returning obscur runtime error - after changing permissions to a subweb (.net app) to different permissions than on its parent ? Isabelle ASP .Net 0 08-11-2004 02:04 PM
checking effective file permissions David K. Wall Perl Misc 3 08-10-2004 01:06 AM
Checking File Permissions blue ASP .Net 1 07-15-2004 01:18 AM



Advertisments