CENG 334 - Project # I

                       

Due date : April, 15th till midnight

           

Team : You can forms teams upto 2 persons.

 

Cheating : Strictly forbidden !!

           

Obligatory :   

·         All the files you write should only include shell programming commands.

·         You MUST use Bourne Again Shelll ( bash )

·         The maximum length of each name and each number is fixed as 20.

·         The name is a combination of alphanumerical charecters together with any number of blanks and numbers can only be in the set of [0-9] .

 

Submission :

·         Write the names and id numbers of team members as a comment to the file "hw1.sh".

·         You can use multiple files, if so, make a tape archieve by using "tar" command.

·         ONLY 1 student per team submit the file(s) using "submit334 hw1.tar" if there are multiple files, else "submit334 hw1.sh ".

·         Note that, whatever the other files, I HAVE TO execute your script as "bash$ ./hw1.sh " hence please be sure about that.

 

Details :           

·         The minor modifications in the input/output design like the number of blanks or the number of "*"s are alright but one must be sure about that the system correctly works semantically.

·         Random team members MAY be called to 'demo' if necessary.

·         Use the newsgroup for questions.

 

Specifications:

           

            In this project, you are going to design a small phone book using 'bash programming'. It will be an interactive program, with a small graphical user interface ( gui ). Firstly, you HAVE TO enter those lines for your gui:     

       

         echo "Would you like to:"

         echo "*********************************************************"

         echo "*  1. Look someone up                                   *"

         echo "*  2. Add someone to the phone book                      *"

         echo "*  3. Remove someone from the phone book             *"

         echo "*  4. Change an entry in the phone book                    *"

         echo "*  5. List all the names and numbers in the phone book  *"

         echo "*  6. Exit this program                                      *"

         echo "*********************************************************"

       

         echo -n "(*) Please select one of the above (1-6):"

        

After, the user enters a number ...

           

 

 - If '1' is pressed :

        

It is for looking someone in the phone book. Weird charecters like '\' won't be considered. 'grep' should be used.

After '1' is pressed, the following menu immidiately appears:

 

       ------------------   Look For Someone  ------------------

                 

       Enter name to lookup :

                 

                 

 Then, the user enters the name, if it exists, you should print it like :

                 

                 

        -----   ali's Record  (pattern = ali)  ------

                 

        ---------------------------------------------

        |ali                                        |

        |345                                        |

        |                                           |

        ---------------------------------------------

                 

        Enter anything to continue "q" to exit :

 

It is obvious that same mechanism continues unless 'q' is pressed. Elsewhere, print :

                 

         1 record displayed...

                 

and turn back to  gui. If the name does not exist,  print :

                 

         0 record displayed...

                                   

and turn back to  gui.

           

           

           

- If '2' is pressed :

           

         ------------------- Add a record ----------------------

                 

         Type in your new entry

         /home/stf4/ozarar/phonebook

         When you are done,type just a single RETURN on the line

         >>

                 

menu should immidiately appears.                                    

                 

" /home/stf4/ozarar/phonebook " is the target of your phonebook file. It may differ since it is a black box to the user but it should be in somewhere accessible. If you want to omit, just press single 'RETURN' or enter in the following way :

                 

         >> redondo

         >> 1048576

         >>  ( single RETURN presses , here ! )

                 

and your system should print and turn back to gui.

                 

 

         **redondo** has been added to the phone book

                 

Note that, at most one entry can be added per pressing a single '2'. If nothing was added, it prints:

                 

         Add operation aborted...

 

        

- If '3' is pressed :  

        

         --------------- Remove A Record --------------------

                 

         Enter name to remove:

                 

     

menu should be appeared. If the user should press RETURN immidiately, same menu re-appears until the name field becomes non-empty. If the name does not exist in the list, the system prints :

           

         0 record deleted..

                   

else for instance you want to delete "Gerhard Weber" , then system outputs:

                   

       

         -----------------------------------------------

         |Gerhard Weber                                 |

         |234345                                        |

         |                                              |

         ------------------------------------------------

                 

         Really, delete?(y/n):

                 

If "n" then it behaves like nothing is deleted but if "y" then

                   

         1 record deleted..

                 

is appeared and system turns back to initial gui.

                 

 

- If '4' is pressed :  

     

         ------------------ Change Record  -----------------

     

         Enter name to change :

                 

     

System will behave like '3' is pressed unless some valid input is entered. If the name does not exist in the list, the system prints :

           

         0 record changed..

                   

else for instance you want to change  "oguz" , then system outputs:

                 

         ------------------------------------------------

         |oguz                                       |

         |2                                             |

         |                                              |

         ------------------------------------------------

                                   

         Really, change?(y/n):

                 

                 

If "n" then it behaves like nothing is deleted but if "y" then the entry for "oguz" appears in a 'Pico' Window. 'Pico' is an editor like 'vi'. The user will make all the modifications in that window and then he/she will press "Control+X" and save by indicating the file name. That file can be in '/tmp' for example. Then,

           

         1 record changed..

                 

is appeared and system turns back to initial gui.

 

 

- If '5' is pressed :  

                 

Assume there are 5 names in the phonebook, the user will see them in the following way:

     

   ------------ List all records -----------------

     

   -----------------------------------------------

         ali                             345

         cem                             23

         murat 1234                      2345

         oguz                                 23411111

         redondo                         2334

         -----------------------------------------------

     

         5 record(s) displayed...

     

         Press RETURN to continue...

                 

        

After the return is pressed, system turns back to the gui. If the phonebook is empty, there is nothing in the table and it will print "0 record displayed...".

                       

- If '6' is pressed :  

                 

System should successfully turn back to "bash$" prompt.