Wednesday, 19 November 2014

OSA: Lower case to upper case conversion and vice-versa

while(true)
do

echo " MENU
______________________________________________________________________________
1)Create a file and write into it
2)Convert Lower to Upper case
3)Convert Upper to Lower case
4)open file
5)Exit"

read choice
case $choice in

1) echo " Create and Write
------------------------------------------------------------------------------
Enter the name of file to be created ->"
read filename
if [ -f $filename ];
then
echo "filename $filename already exists,please try another filename"
else
touch $filename
chmod 777 $filename
# echo "Enter the data to be written into the file ->"
# read data
# cat>$filename
fi
;;

2) echo " Convert from Lower to Upper
------------------------------------------------------------------------------
Loading and translating Existing file :- $filename "
tr '[a-z]' '[A-Z]' <$filename
;;

3) echo " Convert from Upper to Lower
------------------------------------------------------------------------------
Loading and translating Existing file :- $filename "
tr '[A-Z]' '[a-z]' <$filename
;;

4) more $filename
;;

5) echo "Program will be terminated...."
exit 0
;;

esac
done

#tnx for using code from http://www.parazhar.blogspot.in

OSA: Display O.S. name,login name,host-name

while(true)
do

echo " MENU
------------------------------------------------------------------------------
1)Print O.S. name
2)Dispaly login name
3)Display host name
4)Exit
Please enter your choice -> "

read choice
case $choice in

1) echo "OS name -> "
uname
   echo "OS version -> "
cat /proc/version
;;

2) echo "Login name -> "
whoami
;;

3) echo "Host name -> "
hostname
;;

4) echo "program will be terminated "
exit 0
;;

esac
done

OSA: Process mangement

while(true)
do
echo " MENU
------------------------------------------------------------------------------
1)Display current shell
2)Display information of processes
3)Display global priority of processes
4)Change a priority of a process
5)Exit
Enter your choice -> "

read choice
case $choice in

1) echo " displaying current shell
------------------------------------------------------------------------------
"
ps
;;

2) echo " Information of processes
------------------------------------------------------------------------------
"
ps -al
;;

3) echo " Display global priority of processes
------------------------------------------------------------------------------
"
ps -ecl
;;

4) echo " Change priority
------------------------------------------------------------------------------
"
ps -ecl
echo "Enter process ID"
read PID
echo "Enter new priority value for the process"
read priority
renice $PID $priority
echo "Priority has been changed"
;;

5) echo "Program willl be terminated
-----------------------------------------------------------------------------
"
exit 0
;;

esac
done

#tnx for using code from http://www.parazhar.blogspot.in

OSA: Directory- create,delete,display PWD and change directory

while(true)
do
echo " MENU
------------------------------------------------------------------------------
1)Make a new directory
2)Delete a directory
3)Display current working directory
4)Change directory"

read choice
case $choice in

1) echo " New directory
==============================================================================
Enter name of directory to be created ->"
read name
if [ -d $name ];
then
echo "directory already exists, please try another name"
else
mkdir $name
echo "directory has been created successfully"
fi
;;

2) ls
echo " Delete directory
==============================================================================
Enter the name of directory to be deleted ->"
read dname
if [ -d $dname ];
then
rmdir $dname
echo "directory has been deleted  "
else
echo "invalid name, please try a valid directory name"
fi
;;

3) echo " Present working directory
-----------------------------------------------------------------------------"
pwd
;;

4) echo " change directory
-----------------------------------------------------------------------------
Enter the new directory path ->"
read path
cd $path
echo "directory has been changed"
;;

5) echo "Program terminated"
exit 0
;;

esac
done

#tnx for using code from http://www.parazhar.blogspot.in


OSA: User- add,delete,change access permissions for a file

while(true)
do

echo " MENU
------------------------------------------------------------------------------
1)Super User
2)Add user
3)Delete user
4)Change access permissions
5)Exit"

read choice
case $choice in

1) echo "act as super user inorder to add user
=============================================================================="
su
sh 3.sh s

;;

2) echo " add user
==============================================================================
Enter the User name -> "
read name
useradd $name
echo "User added successfully"
;;

3) echo " Delete user
==============================================================================
Enter the name of user to be deleted -> "
read username
userdel
userdel $username
echo "the user has been deleted"
;;

4) echo " change access permissions
==============================================================================
Enter the name of file ->"
read nfile
echo "Enter the access permissions for owner"
read owner
echo "Enter access permissions for group"
read group
echo "Enter access permisiions for user"
read other
chmod $owner$group$other $nfile
echo "Permissions changed"
;;

5) echo "Program terminated"
exit 0
;;

esac
done

OSA: File management (Create,rename,delete and list the file's in present working directory)

while(true)
do

echo  " Enter operation you want to perform
------------------------------------------------------------------------------
1)Create a File
2)Rename a File
3)Delete a File
4)List File's "
echo "enter your choice->"

read choice
case $choice in

1) echo "Enter the name of file to be created"
read filename
if [ -f $filename ];
then
echo "file already exists,please try another name"
else
touch $filename
echo "file has been created successfully"
fi #
;;

2) echo "Enter the name of File to be renamed "
read oldfilename
if [ -f $oldfilename ];
then
echo "enter the new file name to be assigned "
read newfilename
mv $oldfilename $newfilename
else
echo "file doesn't exist please try an existing filename"
ls
fi #
;;


3) echo "Enter name of File to be deleted "
read name
if [ -f $name ];
then
rm -f $name
echo "file has been deleted successfully"
else
echo "No such file ,please try again here are the contents of the directory:"
ls
fi #
;;

4) echo "list of file's in present working directory"
ls
#
;;


5) exit
echo "program terminated"
exit0
;;

esac #
done



Monday, 17 November 2014

Exam Edition ;)


Life is so tied up, everyday i open my eye's up to wake up to a busy day-the more tired i grow of life.
These exams' and academinc'S never seem to end , they just go on till infinity. Beside's this we all know that we'll be judged by the scores on that so called PEICE OF PAPER (degree).
As I'm done with theory paper's i wont be sayin' that it's over instead i'll call it....................