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

V

Vikram Sharma

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
 
T

Tim Hunter

Vikram said:
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
 
V

Vikram Sharma

Tim said:
Permissions are typically specified as octal numbers. 16895 is decimal.

"%o" % 16895 # -> 40777

Oh Yes ! Thanks a lot.. :)

Cheers,
Vikram
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top