On Thu, Nov 15, 2012 at 5:59 PM, Yves Dorfsman <[email protected]> wrote:

> On 2012-11-15 15:45, Edward Ned Harvey (lopser) 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
>>
>
> I don't fully understand what you are trying to do, but bc, dc, and perl
> all know how to do calculation in hex and octal, and are fairly easy to use
> from a script.
>

This.  Or even awk if you dont have perl/python/ruby/whatever available.

If you really have to do this from e.g. Solaris before /usr is mounted, you
may need to provide a statically linked tool under /sbin to help with this.

-- 
brandon s allbery kf8nh                               sine nomine associates
[email protected]                                  [email protected]
unix/linux, openafs, kerberos, infrastructure          http://sinenomine.net
_______________________________________________
Tech mailing list
[email protected]
https://lists.lopsa.org/cgi-bin/mailman/listinfo/tech
This list provided by the League of Professional System Administrators
 http://lopsa.org/

Reply via email to