Write a Shell Script for Simple Database Management System Operation
Write
a Script for Simple Database Management System Operation.
Database
File Contains Following Fields.
EMP_NO
EMP_NAME
EMP_ADDRESS
EMP_AGE
EMP_GENDER
EMP_DESIGNATION
EMP_BASIC_SALARY
Provide
Menu Driven Facility For
VIEW
RECORD BASED ON QUERY
ADD
RECORD
DELETE
RECORD
MODIFY
RECORD.
COUNT
TOTAL NUMBER OF RECORDS
EXIT
File Name : Employee.txt
1,bipin,xyz,27,Male,Professor,10000,true
2,hitesh,xyz,27,Male,Accountant,10000,false
3,ritesh,xyz,27,Male,HOD,20000,true
4,mitesh,xyz,27,Male,Clerk,2000,true
5,jitesh,xyz,27,Male,DBA,5000,true
File Name : ex17.sh
clear
AutoNumber()
{
local eno=0
f=0
for j in `cat Employee.txt`
do
eno=$(echo
"$j" | cut -d "," -f 1)
f=1
done
if [ $f = 1 ]
then
eno=`expr $eno + 1`
else
eno=1
fi
echo $eno
}
Insert()
{
clear
eno=$1
echo "Enter Employee No:
$eno"
echo "Enter Employee Name:
\c"
read enm
echo "Enter Employee Address:
\c"
read eadd
echo "Enter Employee Age :
\c"
read eage
echo "Enter Employee Gender:
\c"
read egen
echo "Enter Employee
Designation : \c"
read edes
echo "Enter Employee Basic
Salary : \c"
read ebal
echo "$eno,$enm,$eadd,$eage,$egen,$edes,$ebal,true"
>> Employee.txt
echo " Insert Sucessfully "
}
Display()
{
clear
echo "__________________________________________________"
echo " Employee
Details "
echo "__________________________________________________"
echo "__________________________________________________"
echo "#ENO \t ENAME \t\t EADDR
\t\t\t EAGE \t EGEN \t EDES \t\t EBAL"
for j in `cat Employee.txt`
do
eno=$(echo
"$j" | cut -d "," -f 1)
enm=$(echo
"$j" | cut -d "," -f 2)
eadd=$(echo
"$j" | cut -d "," -f 3)
eage=$(echo
"$j" | cut -d "," -f 4)
egen=$(echo
"$j" | cut -d "," -f 5)
edes=$(echo
"$j" | cut -d "," -f 6)
ebal=$(echo
"$j" | cut -d "," -f 7)
tfval=$(echo
"$j" | cut -d "," -f 8)
if [ $tfval =
"true" ]
then
echo
"$eno \t $enm \t\t $eadd \t\t $eage \t $egen \t $edes \t $ebal"
fi
done
echo "__________________________________________________"
}
Search()
{
clear
echo "Enter Employee NO:
\c"
read no
echo "__________________________________________________"
echo " Employee Details "
echo "__________________________________________________"
flag=0
for j in `cat Employee.txt`
do
eno=$(echo
"$j" | cut -d "," -f 1)
enm=$(echo
"$j" | cut -d "," -f 2)
eadd=$(echo
"$j" | cut -d "," -f 3)
eage=$(echo
"$j" | cut -d "," -f 4)
egen=$(echo
"$j" | cut -d "," -f 5)
edes=$(echo
"$j" | cut -d "," -f 6)
ebal=$(echo
"$j" | cut -d "," -f 7)
tfval=$(echo
"$j" | cut -d "," -f 8)
if [ $no -eq $eno ]
&& [ $tfval = "true" ]
then
flag=1
echo "________________________________________"
echo "________________________________________"
echo
" ENo : $eno EName : $enm "
echo "________________________________________"
echo
" EAdd : $eadd "
echo
" EAge : $eage "
echo " EGen : $egen "
echo "________________________________________"
echo
" EDes : $edes "
echo "________________________________________"
echo
" ESal : $ebal "
echo "________________________________________"
fi
done
if [ $flag = 0 ]
then
echo " No
Record Found "
fi
echo "__________________________________________________"
}
Delete()
{
clear
f=0
echo "Enter Employee NO:
\c"
read no
for j in `cat Employee.txt`
do
eno=$(echo
"$j" | cut -d "," -f 1)
enm=$(echo
"$j" | cut -d "," -f 2)
eadd=$(echo
"$j" | cut -d "," -f 3)
eage=$(echo
"$j" | cut -d "," -f 4)
egen=$(echo
"$j" | cut -d "," -f 5)
edes=$(echo
"$j" | cut -d "," -f 6)
ebal=$(echo
"$j" | cut -d "," -f 7)
if [ $no -eq $eno ]
then
f=1
line=$(echo
"$eno,$enm,$eadd,$eage,$egen,$edes,$ebal,false")
fnm=`cat
Employee.txt`
d=$(echo
"$fnm" | sed s/$j/$line/g )
echo $d >
Employee.txt
echo
" Delete Successfully "
fi
done
if [ f = 0 ]
then
echo " No Record Found "
fi
}
Update()
{
clear
echo "Enter Employee NO:
\c"
read no
for j in `cat Employee.txt`
do
eno=$(echo
"$j" | cut -d "," -f 1)
enm=$(echo
"$j" | cut -d "," -f 2)
eadd=$(echo
"$j" | cut -d "," -f 3)
eage=$(echo
"$j" | cut -d "," -f 4)
egen=$(echo
"$j" | cut -d "," -f 5)
edes=$(echo
"$j" | cut -d "," -f 6)
ebal=$(echo
"$j" | cut -d "," -f 7)
if [ $no -eq $eno ]
then
echo
"______________Enter New Record______________"
echo
"Enter Employee No: $eno"
echo
"Enter Employee Name: \c"
read enm
echo
"Enter Employee Address: \c"
read eadd
echo
"Enter Employee Age : \c"
read eage
echo
"Enter Employee Gender: \c"
read egen
echo
"Enter Employee Designation : \c"
read edes
echo
"Enter Employee Basic Salary : \c"
read ebal
line=$(echo
"$eno,$enm,$eadd,$eage,$egen,$edes,$ebal,true")
#line=$(echo
"$eno,$snm,$m1,$m2,$m3,$total,$per,true")
fnm=`cat
Employee.txt`
d=$(echo
"$fnm" | sed s/$j/$line/g )
echo $d >
Employee.txt
echo
" Update
Sucessfully
"
fi
done
}
while
[ true ]
do
echo " _______________________________"
echo
" 1. Insert "
echo
" 2. Delete "
echo
" 3. Update "
echo
" 4. Display "
echo
" 5. Search "
echo
" 6. Exit "
echo
"Enter Choice: \c"
read
ch
case
$ch in
1)
nxtSrNo=$(AutoNumber)
Insert $nxtSrNo
;;
2) Delete ;;
3) Update ;;
4) Display ;;
5) Search ;;
6) break;;
*) echo " Wrong Choice "
esac
done
Subscribe to:
Post Comments (Atom)
Subjects
- WordPress
- Mobile Computing-4649303 Practical Solution
- Android Programming New Syllabus Theory
- PHP LAMP Question Bank
- PHP LAMP Theory
- Step by Step Android Example
- Android Practical
- Android Theory
- Android Question Bank
- Networking FON Practical
- Networking FON Theory
- OS Practical
- OS Theory
- HTML
- JavaScript
- J2EE WTAD Theory
- J2EE WTAD Question Bank
- J2EE WTAD Quick Guide
- J2EE WTAD GTU Papers
- J2EE WTAD Practical
- Python
- JAVA Theory
- JAVA Practical
- MIS
Categories
- Android (55)
- CSS (3)
- Configure Tomcat7 (2)
- Decryption (16)
- Difference (1)
- Encryption (16)
- Error Detection and Correction Techniques (3)
- FON (27)
- Framing Technic (2)
- J2EE (29)
- JAVA (13)
- JavaScript (19)
- OS (17)
- PHP (11)
- Protocol (3)
- SERVER SOCKET PROGRAMING (7)
- Servlet (13)
- WTAD (34)
- c (11)
- install Tomcat (2)
- linux (8)
- shell script (33)
- unix (22)
Blog Archive
-
▼
2012
(79)
-
▼
November
(15)
- unix grep command
- Write a script to learn command line argument
- Write a script to display the last modified file
- Write a script to display all lines of a file in a...
- Write a script to display all words of a file in a...
- Write a script to check whether a given number is ...
- Write a script to check whether a given string is ...
- Write a shell script to mathematics calculation
- Write a shell script to Perform Following String O...
- Write a Shell Script for Simple Database Managemen...
- Write a shell script to check whether the named us...
- Write a script which reads a text file and output ...
- Write a script to make following file and director...
- Write a shell script to add the statement #include...
- Write a script to implement the following commands...
-
▼
November
(15)
Total Pageviews
© BipinRupadiya.com. Powered by Blogger.
1 comments:
why [ $tfval = "true" ] is used here??? and what is "$tfval"???
Post a Comment