473,394 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Readin File permissions?

How do i read a file permission?

i know that ls -l *filename* will list all information about the file including file permissions eg -rwxr-xr-x 1 norman.thai users 187 Jan 15 10:33 firstline...

how do i read just the file permission tho to use be used as a variable...
-rwxr-xr-x

i also understand that the file permissions can be read as binary 000 000 000...
Jan 21 '08 #1
4 2147
ashitpro
542 Expert 512MB
How do i read a file permission?

i know that ls -l *filename* will list all information about the file including file permissions eg -rwxr-xr-x 1 norman.thai users 187 Jan 15 10:33 firstline...

how do i read just the file permission tho to use be used as a variable...
-rwxr-xr-x

i also understand that the file permissions can be read as binary 000 000 000...
use this command

ls -l *filename* | awk {'print $1'}
Jan 22 '08 #2
use this command

ls -l *filename* | awk {'print $1'}
Hey thanks for your reply. However i've not used awk or sed before and i'm not suppose to use it for this exercise. The full task is to use a file as an argument then display the permissions in a certain format like so :-

READ WRITE EXECUTE
OWNER LEE.BALLANCORE YES YES NO
GROUP USERS YES NO NO
EVERYBODY NO NO NO

i jus want to know how to read the permissions in binary so i can use if statements to create the text...if ya get me, sorry if it sounds a bit of a woffle
Jan 22 '08 #3
ashitpro
542 Expert 512MB
Hey thanks for your reply. However i've not used awk or sed before and i'm not suppose to use it for this exercise. The full task is to use a file as an argument then display the permissions in a certain format like so :-

READ WRITE EXECUTE
OWNER LEE.BALLANCORE YES YES NO
GROUP USERS YES NO NO
EVERYBODY NO NO NO

i jus want to know how to read the permissions in binary so i can use if statements to create the text...if ya get me, sorry if it sounds a bit of a woffle
If I am not wrong, you are trying to achieve this with C code..correct me If I am wrong.

Check out this link..

http://www.gnu.org/software/libc/manual/html_node/Permission-Bits.html#Permission-Bits
Here are enough macros to read the permission for file.

If you are doing this under shell script..then no option other that 'awk'.
Jan 22 '08 #4
numberwhun
3,509 Expert Mod 2GB
Another good link to read is this one.

Regards,

Jeff
Jan 23 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Fran Tirimo | last post by:
I am developing a small website using ASP scripts to format data retrieved from an Access database. It will run on a Windows 2003 server supporting FrontPage extensions 2002 hosted by the company...
2
by: Fran Tirimo | last post by:
I am developing a small website using ASP scripts to format data retrieved from an Access database. It will run on a Windows 2003 server supporting FrontPage extensions 2002 hosted by the company...
15
by: David Thielen | last post by:
Hi; My ASP.NET app (C# calling J# under .net 2.0) creates a png file in a subdirectory to display as part of the created page. However, the bitmap will not display due to a security violation. ...
1
by: boriss111 | last post by:
Hi, How can I read interer number form the *.txt file? I have a matrix of integer numbers stored in *.txt file, like this 3 7 7 12 12 10 14 7 8 and I have to read those numbers as numbers...
13
by: Rick | last post by:
The following code will enter an infinate loop when in ReadChars. I can only make it happen when reading a Stream and with this particular XML. If I use the ReadInnerXml call rather than my own...
2
by: Marc | last post by:
So i have a text file where each line represents a button name. What the code I need to read this file and creatre a new button from each line.. so far I just have code to read the whole...
1
by: Poto | last post by:
Hello: i need to read a file line by line because there is diferent information in each line that i need to take out separatly, i'm using the while construction like this while ($file = <FILE>){...
11
by: Victor Lagerkvist | last post by:
Greetings, I know it's usually a bad habit to include several questions in a single message, but they are quite related. I have declared and defined a function named readin, whose purpose is to...
2
by: beary | last post by:
Hello everyone, I posted this in unix/linux but it received no replies, so I assume it was the wrong forum. I'm trying here. I'm in way over my head with file permissions. The directory and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.