Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss] test for *other* write permissions



On Thu, Nov 15, 2012 at 5:45 PM, Edward Ned Harvey (blu)
<blu at nedharvey.com>wrote:

> > If using "stat" you can also get the perms in 755 format.  From here, I
> can
> > easily do a bitwise & with 2, and I can easily find the world write bit.
>  But bash
> > arithmetic doesn't view the number "755" in octal...  It operates
> decimal.  So I
> > can't bitwise & with 16, or with 020.  I have to strip off the last
> character, and
> > then bitwise 75 with & 2.  So once again, given my previous comments
> about
> > leading and trailing spaces and stuff, plus, not knowing how to get the
> nth
> > character of a string, I'm not really sure there's a good solution here.
>
> My next best idea is to take the number 755, divide by 10 to get 75, and
> then & 2


How about using Python? os.stat() will give you all the info you need:
http://docs.python.org/2/library/stat.html

gcm



BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org