|
|
|
|
|
|
| Author |
Message |
Anoop *nix forums beginner
Joined: 20 Jul 2006
Posts: 5
|
Posted: Thu Jul 20, 2006 1:19 pm Post subject:
Checking File permissions
|
|
|
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 |
|
| Back to top |
|
 |
Avell Diroll *nix forums beginner
Joined: 23 Dec 2005
Posts: 9
|
Posted: Thu Jul 20, 2006 1:56 pm Post subject:
Re: Checking File permissions
|
|
|
Anoop wrote:
| Quote: | 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 |
|
| Back to top |
|
 |
taleinat@gmail.com *nix forums beginner
Joined: 25 Apr 2006
Posts: 14
|
Posted: Fri Jul 21, 2006 12:46 pm Post subject:
Re: Checking File permissions
|
|
|
Anoop wrote:
| Quote: | 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.
| Quote: | 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. |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Sat Nov 22, 2008 9:15 pm | All times are GMT
|
|
Car Finance | MPAA | Myspace Layouts | Loan | Dominios
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|