Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Ruby equivalent to `find . -perm -g+rw -ls`

Reply
Thread Tools

Ruby equivalent to `find . -perm -g+rw -ls`

 
 
Bil Kleb
Guest
Posts: n/a
 
      11-17-2008
Hi,

I can't find a Ruby equivalent to

find . -perm -g+rw -ls

Currently, it looks like I'll need to combine,

File.stat(file).mode

with something like Hal Fulton's sym2oct,

http://blade.nagaokaut.ac.jp/cgi-bin...uby-talk/96956

hacked into Daniel Berger's file-find gem,

http://blade.nagaokaut.ac.jp/cgi-bin...by-talk/248981

and require 'etc' to pull out the user and group names instead of uids
and gids?

Is there an alternative to all this yak shaving?

Thanks,
--
http://twitter.com/bil_kleb
 
Reply With Quote
 
 
 
 
Rolando Abarca
Guest
Posts: n/a
 
      11-17-2008
On Nov 17, 2008, at 11:21 AM, Bil Kleb wrote:

> Hi,
>
> I can't find a Ruby equivalent to
>
> find . -perm -g+rw -ls
>
> Currently, it looks like I'll need to combine,
>
> File.stat(file).mode
>
> with something like Hal Fulton's sym2oct,
>
> http://blade.nagaokaut.ac.jp/cgi-bin...uby-talk/96956
>
> hacked into Daniel Berger's file-find gem,
>
> http://blade.nagaokaut.ac.jp/cgi-bin...by-talk/248981
>
> and require 'etc' to pull out the user and group names instead of uids
> and gids?
>
> Is there an alternative to all this yak shaving?


maybe something like this?

rolando:test_perm rolando$ ls -l
total 8
-rw-rw-r-- 1 rolando staff 0 Nov 17 12:12 1
-rw-r--r-- 1 rolando staff 0 Nov 17 12:13 2
-rw-r--r-- 1 rolando staff 77 Nov 17 12:21 perm.rb

rolando:test_perm rolando$ find . -perm -g+rw -ls
1510804 0 -rw-rw-r-- 1 rolando staff 0 Nov 17
12:12 ./1

rolando:test_perm rolando$ ruby perm.rb
["./1"]
rolando:test_perm rolando$ cat perm.rb
# NOTE: 060 == g+rw
p Dir["./**/*"].select { |f| File.stat(f).mode & 060 == 060 ? true :
nil }


> Thanks,
> --
> http://twitter.com/bil_kleb



regards,
--
Rolando Abarca M.




 
Reply With Quote
 
 
 
 
Bil Kleb
Guest
Posts: n/a
 
      11-17-2008
Hi,

Rolando Abarca <(E-Mail Removed)> wrote:
>
> maybe something like this?
> [..]
> rolando:test_perm rolando$ cat perm.rb
> # NOTE: 060 == g+rw


This is what I'm reduced to doing now. It just feels wrong
for me to have to resort to octal -- it's not at the
correct abstraction level as evidenced by your comment.

> p Dir["./**/*"].select {
> |f| File.stat(f).mode & 060 == 060 ? true : nil }


You don't need the '? true : nil' part AFAICT -- the
first conditional satisfies select.

Regards,
--
http://twitter.com/bil_kleb
 
Reply With Quote
 
Daniel Berger
Guest
Posts: n/a
 
      11-17-2008
Bil Kleb wrote:
> Hi,
>
> I can't find a Ruby equivalent to
>
> find . -perm -g+rw -ls
>
> Currently, it looks like I'll need to combine,
>
> File.stat(file).mode
>
> with something like Hal Fulton's sym2oct,
>
> http://blade.nagaokaut.ac.jp/cgi-bin...uby-talk/96956
>
> hacked into Daniel Berger's file-find gem,
>
> http://blade.nagaokaut.ac.jp/cgi-bin...by-talk/248981
>
> and require 'etc' to pull out the user and group names instead of uids
> and gids?
>
> Is there an alternative to all this yak shaving?


Not at the moment, but both are excellent ideas. I've submitted them myself at:

http://rubyforge.org/tracker/index.p...=735&atid=2912
http://rubyforge.org/tracker/index.p...=735&atid=2912

Supporting strings for users and groups is trivial. Supporting symbolic
permissions will be more of a hassle.

Regards,

Dan


 
Reply With Quote
 
Rolando Abarca
Guest
Posts: n/a
 
      11-17-2008
On Nov 17, 2008, at 3:31 PM, Bil Kleb wrote:

> You don't need the '? true : nil' part AFAICT -- the
> first conditional satisfies select.


that's correct.

> Regards,
> --
> http://twitter.com/bil_kleb



regards,
--
Rolando Abarca M.





 
Reply With Quote
 
Bil Kleb
Guest
Posts: n/a
 
      11-17-2008
Hi,

Daniel Berger <(E-Mail Removed)> wrote:
> Bil Kleb wrote:
> > [..] Is there an alternative to all this yak shaving?

>
> Not at the moment, but both are excellent ideas.
> I've submitted them myself at:
>
> [http://rubyforge.org/tracker/?atid=2912&group_id=735]


Excellent; thanks.

Regards,
--
Bil
http://fun3d.larc.nasa.gov
 
Reply With Quote
 
Daniel Berger
Guest
Posts: n/a
 
      11-17-2008
Bil Kleb wrote:
> Hi,
>
> Daniel Berger <(E-Mail Removed)> wrote:
>> Bil Kleb wrote:
>>> [..] Is there an alternative to all this yak shaving?

>> Not at the moment, but both are excellent ideas.
>> I've submitted them myself at:
>>
>> [http://rubyforge.org/tracker/?atid=2912&group_id=735]

>
> Excellent; thanks.


I've already tested and committed the changes for the :user and :group changes.
They'll be part of release 0.2.2. I should have a release out this week.

I'll save the erm changes for 0.2.3 after I've had the chance to review some
of the code I've seen online.

Regards,

Dan

 
Reply With Quote
 
Daniel Berger
Guest
Posts: n/a
 
      11-19-2008
Hi,

On Nov 17, 11:56 am, Bil Kleb <(E-Mail Removed)> wrote:
> Hi,
>
> Daniel Berger <(E-Mail Removed)> wrote:
> > BilKlebwrote:
> > > [..] Is there an alternative to all this yak shaving?

>
> > Not at the moment, but both are excellent ideas.
> > I've submitted them myself at:

>
> > [http://rubyforge.org/tracker/?atid=2912&group_id=735]

>
> Excellent; thanks.


file-find 0.2.2 has been released, which now supports names as well as
id's for the :name and :group options (on Unix, anyway).

Regards,

Dan

 
Reply With Quote
 
Daniel Berger
Guest
Posts: n/a
 
      12-10-2008


On Nov 17, 7:21=A0am, Bil Kleb <(E-Mail Removed)> wrote:
> Hi,
>
> I can't find a Ruby equivalent to
>
> =A0 find . -perm -g+rw -ls
>
> Currently, it looks like I'll need to combine,
>
> =A0 File.stat(file).mode
>
> with something like Hal Fulton's sym2oct,
>
> =A0http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/96956
>
> hacked into Daniel Berger'sfile-findgem,
>
> =A0http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/248981
>
> and require 'etc' to pull out the user and group names instead of uids
> and gids?
>
> Is there an alternative to all this yak shaving?


I just released file-find 0.2.4 which now does all your yak shaving
for you, i.e. it now supports symbolic permissions, too.

Regards,

Dan

 
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
Any equivalent to Ruby's 'hpricot' html/xpath/css selector package? Kenneth McDonald Python 6 12-30-2008 01:38 PM
ruby %w equivalent Antoine De Groote Python 24 09-30-2006 10:15 AM
#!/usr/bin/ruby , #!/usr/bin/ruby -w , #!/usr/bin/ruby -T?, #!/usr/bin/ruby -T1... anne001 Ruby 1 04-23-2006 03:02 PM
Ruby on Rails Job Site -- Is there a Python equivalent? Ray Python 3 12-02-2005 03:13 PM
Ruby on Rails or Perl's Maypole..is there a Python equivalent Gary Nutbeam Python 12 03-07-2005 04:40 PM



Advertisments