Professional Documents
Culture Documents
By:
R.J.
CONTENT
1. Customer Database
2. Train Database
Tseat
Tfair
SELECTION : Calls add_passenger function where
Option a chossen it reads data from keyboard & enters
a) Add Passenger
customer details (Customer Name ,
details
Customer Age ,Customer Mobile No ,
b) View Specific Customer Sex) into Customer details
train details database.
c) Add train
details
d) View the Calls find_trains function &
customer details searches specific train details on
Option b chossen
e) Exit the basis of entered source ,
destination & date of departure .
get_confirm()
This function is used to get confirmation from the user for adding
the information in the database. If user types yes then information is
added to database otherwise it gets cancelled. Here variable ‘x’ is
used to read yes or no from the keyboard.
set_menu_choice()
This function is used to display the options on the terminal.
‘menu_choice’ variable reads user choice from the terminal.
insert_recordCustomer()
This function is used to record permanently customer information
in the customer_details database.
insert_recordTrain()
This function is used to record permanently train information in
the train_details database.
add_passenger()
This function is used to read passenger details and(calling
get_confimation()) after getting confirmation from user adds
data(calling insert_recordCustomer)in database.
CName – reads customer name
Cage – reads customer age
CMob – reads customer mobile number
CS – reads customer sex
add_train()
This function is used to read passenger details and(calling
get_confimation()) after getting confirmation from user adds
data(calling insert_recordTrain)in database.
Tno – reads train number
Tname – reads train name
Tsrc – reads source of the train
Tdes – reads destination of the train
Tdep – reads departure time of the train
Tarv – reads arrival time of the train
Ttype – reads whether coach of train is ac , 2s , sleeper etc
Tquota – reads quota like student , tatkal etc.
Tfair – reads fair per person
Tseat – reads total seat availability
view_trainDetails()
This function is used to view or lists all the train on the terminal
from train_details database.
view_customerDetails()
This function is used to view or lists all the train on the terminal
from customer_details database.
find_trains()
This function is used to find the train details on the basis of user
requirements(train source , train destination & date of journey) from
train_details database.
The grep filter searches a file for a particular pattern of characters,
and displays all lines that contain that pattern
grep -i ignores, case for matching.
grep -i "$src.*$des.*$d" $db1 > $temp_file : stores the found record
in temp_file.
linesfound : stores the count of line present in temp_file
get_return(){
printf '\tPress return\n'
read x
return 0
}
get_confirm(){
printf '\tAre you sure?\n'
while true
do
read x
case "$x" in
y|yes|Y|Yes|YES)
return 0;;
n|no|N|No|NO)
printf '\ncancelled\n'
return 1;;
*) printf 'Please enter yes or no';;
esac
done
}
set_menu_choice(){
clear
printf 'Options:-'
printf '\n'
printf '\ta) Add Passenger details\n'
printf '\tb) View Specific train details\n'
printf '\tc) Add train details\n'
printf '\td) View the customer details\n'
printf '\te) Exit\n'
printf 'Please enter the choice then press return\n'
read menu_choice
return
}
insert_recordCustomer(){
echo $* >>$db2
return
}
insert_recordTrain(){
echo $* >>$db1
return
}
add_passenger()
{
printf 'Enter CUSTOMER NAME:-'
read tmp
CName=${tmp%%,*}
add_train()
{
printf 'Enter TRAIN NUMBER:-'
read tmp
Tno=${tmp%%,*}
view_trainDetails(){
printf "List of train are\n"
cat $db1
get_return
return
}
view_customerDetails(){
printf "List of Customers are\n"
cat $db2
get_return
return
}
find_trains(){
echo "Enter WHERE TO WHERE to find:"
read src
read des
echo "Enter date : "
read d
grep -i "$src.*$des.*$d" $db1 > $temp_file
linesfound=`cat $temp_file|wc -l`
printf '\n\n\n'
printf 'Mini RAILWAY SYSTEM'
sleep 1
quit="n"
while [ "$quit" != "y" ];
do
rm -f $temp_file
echo "Finished"
exit 0
OUTPUT
customer_details
abc 30 1234567890 M
def 22 2145698730 F
train_details
1234 durunto hwh pnbe 30.04.2019 8:00pm 4:30am ac general 990 240
1234 Durunto hwh pnbe 30.04.2019 8:00pm 4:30am sleeper general
350 600
2345 akal kol pnbe 30.04.2019 7:40am 4:30pm ac general 760 115
2345 akal kol pnbe 30.04.2019 7:40am 4:30pm sleeper general 350 600