If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Checking File Permissions Before Using it ?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-15-05, 16:48
sbk sbk is offline
Registered User
 
Join Date: Jan 2005
Posts: 18
Question Checking File Permissions Before Using it ?

Hi all,

I need to check the permissions of a file before using that file to access a Web Service. I need to check that only the 'user' has 'rwx' permissions, at the same time, the 'group' and 'others' part of the permissions string should not contain anything. That is, I should have a permission string as shown below for a file:

-rwx------

Can anybody tell me how to do this? A script should be very helpful.

I appreciate your time.

Thanks a lot,
sbk
Reply With Quote
  #2 (permalink)  
Old 02-16-05, 09:45
ducasio ducasio is offline
Registered User
 
Join Date: Aug 2004
Location: Rome, Italy
Posts: 81
check file permissions

Use this:

if test `ls -l anasti-tel1-ritp.txt| awk '{if($1=="-rwxr-----") print 0;else print 1}'` -eq 0
then echo "OK"
else echo "KO"
fi

I hope it's worthy for you.


Bye bye,
ducasio
Reply With Quote
  #3 (permalink)  
Old 02-16-05, 13:48
sbk sbk is offline
Registered User
 
Join Date: Jan 2005
Posts: 18
Thanks ducasio,

It worked !
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On