Monday, January 20, 2014

Unix and Shell Programming - File Access Permission

with 0 Comment
clear
while true
do
echo
echo "File Access Permission"
echo "--------------------"
echo "1.Symbolic Mode"
echo "2.Absolute Mode"
echo "3.Exit"
echo "Enter your choice"
read n
case $n in

1)
echo "Symbolic Mode"
echo "-------------"
echo "Enter your File name"
read fn
if test -f $fn
then
echo "File is Present"
ls -l $fn
echo "Enter your Symbolic Entries(u,g,o)"
read se
echo
echo "Symbolic Operation(+,-,=)"
read so
echo
echo "Symbolic Permission(r,w,x)"
read sp
chmod $se$so$sp $fn
ls -l $fn
else
echo "File is Not Present"
fi
;;

2)
echo "Absolute Mode"
echo "------------"
echo "Enter the File Name"
read fn
if test -f $fn
then
echo "File is Present"ls -l $fn
echo "1.Execute"
echo "2.Write"
echo "3.Write && Execute"
echo "4.Read"
echo "5.Read && Execute"
echo "6.Read && Write"
echo "7.Read,Write && Execute"
echo "Enter your Rights for Users"
read u
echo "Enter the Rights for group"
read g
echo "Enter the Rights for others"
read o
chmod $u$g$o $fn
ls -l $fn
else
echo "File is Not Present"
fi
;;

3)
echo "Exit"
exit
;;
esac
done

-------------
OUTPUT:
-------------
File Access Permission
----------------------------
1.Symbolic Mode
2.Absolute Mode
3.Exit

Enter your choice
1

Symbolic Mode
-------------------
Enter the File Name
cmp1

File is Present

-rw-rw-r--     1 smca13  smca13    39 Aug 25  13:47 cmp1

Enter the Symbolic Entries(u,g,o)
u

Symbolic Operation(+,-,=)
+

Symbolic Permission(r,w,x)
x
-rwxrw-r--   1 smca13 smca13   39 Aug 25  13:47  cmp1

Enter your choice
2

Absolute Mode
------------------
Enter the File Name
cmp

File is Present
-w-r--r-- 1 smca13    smca13    39Aug31  13:48 cmp
1.Execute
2.Write
3.Write && Execute
4.Read
5.Read && Execute
6.Read && Write
7.Read,Write && Execute

Enter the Rights for Users
5

Enter the Rights for Group
3

Enter the Rights for Others
2

-r-x-wx-w-  1 smca13   smca13     39 Aug 31    13:48 cmp

Enter your choice
3
Exit

0 comments:

Post a Comment

Powered by Blogger.

Blog Archive