Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Using File:Stat.mode method to find file permissions in Unix

Reply
Thread Tools

Using File:Stat.mode method to find file permissions in Unix

 
 
Vikram Sharma
Guest
Posts: n/a
 
      12-01-2008
Hi,

I am trying to find the permissions on a file, using mode method of
File:Stat.

Code :

s = File.stat(file_name)
p s.mode

For a file having 777 permissions, this prints : 16895

Any Idea on what does this number imply ?

Thanks,
Vikram
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Tim Hunter
Guest
Posts: n/a
 
      12-01-2008
Vikram Sharma wrote:
> Hi,
>
> I am trying to find the permissions on a file, using mode method of
> File:Stat.
>
> Code :
>
> s = File.stat(file_name)
> p s.mode
>
> For a file having 777 permissions, this prints : 16895
>
> Any Idea on what does this number imply ?
>
> Thanks,
> Vikram


Permissions are typically specified as octal numbers. 16895 is decimal.

"%o" % 16895 # -> 40777

--
RMagick: http://rmagick.rubyforge.org/

 
Reply With Quote
 
 
 
 
Vikram Sharma
Guest
Posts: n/a
 
      12-01-2008
Tim Hunter wrote:
> Vikram Sharma wrote:
>> For a file having 777 permissions, this prints : 16895
>>
>> Any Idea on what does this number imply ?
>>
>> Thanks,
>> Vikram

>
> Permissions are typically specified as octal numbers. 16895 is decimal.
>
> "%o" % 16895 # -> 40777


Oh Yes ! Thanks a lot..

Cheers,
Vikram
--
Posted via http://www.ruby-forum.com/.

 
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
Unix-style permissions on NTFS? Tester Computer Support 4 12-02-2006 11:13 PM
In-depth documenation on User Permissions, Group Permissions, ACLs, DCLs etc. Curt K ASP .Net 0 11-03-2006 04:54 PM
Unix permissions in Java frank Java 3 08-20-2005 03:14 AM
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
Re: Permissions - giving "everyone" full permissions is bad ? Scott Allen ASP .Net 0 07-13-2004 08:54 PM



Advertisments