Write a multi-module C program to manage an auto-parts database for a manufactory.
help translate the bash script into c
#! /bin/sh
#Project 2 CSC 3320
#echo menu test program
stop=0 # reset loop termination flag.
while test $stop -eq 0 # loop until done.
do
cat << ENDOFMENU # display menu.
Main Menu
(e) Edit Submenu
(r) Report Submenu
(q) Quit
ENDOFMENU
echo -n 'your choice?' # prompt.
read reply # read response.
echo
case $reply in # process response.
"e")
echo "Edit Submenu:"
./EditSubmenu.sh # go to Edit submenu
;;
"r")
echo "Report Submenu:"
./ReportSubmenu.sh # go to report submenu
;;
"q")
stop=1 # set loop termination flag.
;;
*) # default.
echo illegal choice # error.
;;
esac
done
#!/bin/sh
#Project1 add submenu
echo -n "Name:" #use if here to make sure the part is not there
read name
echo -n "Operator's Name:"
read operator
echo ${name}:in:$date:${operator} >> part.txt
echo "A new auto part is added into your data book."
#!/bin/sh
#Project1 delete submenu
echo -n "Name:"
read name
sed "/^${name}:/d" part.txt > parttemp.txt
cp parttemp.txt part.txt
rm parttemp.txt
echo "$name is removed from your part database."
#!/bin/sh
#project1 display submenu
echo -n "Name:"
read name
egrep -i "^$name" part.txt | awk -F: -f display.awk
#!/bin/sh
#project1 return submenu
echo -n "Name:"
read name
grep -i "$name" part.txt | sed s/out/in/g part.txt
[asahib1@qubit ~]$ vi checkout.sh
#!/bin/sh
#project 1 checkout part submenu
echo -n "Name:"
read name
echo -n "Borrower's name:"
read borrower
borrower=$borrower
egrep -i "$name" part.txt | sed s/in/out/g part.txt
{
printf "%s:%s:%s:%s:%s\n\n", $1,$2,$3,$4,$5;
}
#!/bin/sh
#echo submenu test program
stop=0 # reset loop termination flag.
while test $stop -eq 0 # loop until done.
do
cat << ENDOFSUBMENU # display menu.
Edit Submenu
(a) Add an auto part
(p) Display an auto part
(i) Return an auto part
(o) Check an auto part
(d) Delete an auto part
(q) Return to main Menu
ENDOFSUBMENU
echo -n 'your choice?' # prompt.
read reply # read response.
echo
case $reply in # process response.
"a")
echo "Add an auto part:"
./add.sh # go to add submenu
;;
"p")
echo "Display an auto part:"
./display.sh # go to display submenu
;;
"i")
echo "Return an auto part:"
./return.sh # go to return submenu
;;
"o")
echo "Check an auto part:"
./checkout.sh # go to check submenu
;;
"d")
echo "Delete an auto part:"
./delete.sh # go to delete submenu
;;
"q")
stop=1
# go to Main menu
;;
*) # default.
echo illegal choice # error.
;;
esac
done
#! /bin/sh
# menu test program
stop=0 # reset loop termination flag.
while test $stop -eq 0 # loop until done.
do
cat << ENDOFMENU # display menu.
Report Submenu:
(n) Sort by Name
(o) Sort by Operator's name
(s) Sort by Status
(q) Return to Main Menu
ENDOFMENU
echo -n 'your choice?' # prompt.
read reply # read response.
echo
case $reply in # process response.
"n")
sort -t: +0 -1 part.txt | awk -F: -f display.awk
;;
"o")
sort -t: +1 -2 part.txt | awk -F: -f display.awk
;;
"s")
sort -t: +2 -3 part.txt | awk -F: -f display.awk
;;
"q")
stop=1 # set loop termination flag.
;;
*) # default.
echo illegal choice # error.
;;
esac
done