DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 5th July 2011
fossala's Avatar
fossala fossala is offline
Real Name: David
Fdisk Soldier
 
Join Date: Feb 2011
Location: Cornwall, UK
Posts: 58
Default Address book

I know there are plenty of addressbook apps that do this. It's more for learning rather than that I need it.
My code is not complete at all just started.
Code:
  1 #!/bin/sh
  2 #phonebook
  3 echo "Would you like to 'add' 'edit' or 'read' the database?"
  4 echo -n "Enter Choice: "
  5 read choice
  6         if [ $choice = add ]; then
  7                 echo -n "Please enter name for the database: "
  8                 read name
  9                 echo $name >> ~/.pbook/$name
 10                 echo "---------------------------"
 11                 echo -n "Enter Home Phone number [number/NO]: "
 12                 read -e number
 13                         if [ $number = NO ]; then
 14                                 echo ""
 15                         else
 16                                 `echo "Home number: $number" >> ~/.pbook/$name`
 17                         fi
 18                 echo -n "Enter email address [email/NO]: "
 19                 read -e eaddress
 20                         if [ $eaddress = NO ]; then
 21                                 echo ""
 22                         else
 23                                 `echo "Email address: $eaddress" >> ~/.pbook/$name`
 24                         fi
 25         elif [ $choice = read ]; then
 26                 echo -n "Please enter the clients name or list: "
 27                 read -e username
 28                         if [ $username = list ]; then
 29                                 ls ~/.pbook
 30                         else
 31                                 cat ~/.pbook/$username
 32                         fi
 33         else
 34                 echo "That is not a vailid choice"
 35         fi
What I want to is once I choose "list" under "read" it goes back to re ask me the name instead of exiting. I could do this by just adding the $username = part again but I was wondering If there was an easier/more clean way of doing this?
Reply With Quote
 

Tags
shell


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
C: address of an int in an array in a struct? xmorg Programming 3 18th April 2011 02:31 PM
could not look up internet address for .lan idefix FreeBSD General 2 31st January 2009 02:22 PM
Static IP address problem rex FreeBSD General 2 25th November 2008 08:53 PM
MAC address to IP rex FreeBSD General 9 11th November 2008 07:06 PM
Asking about IPv6 address berlowin Off-Topic 2 9th July 2008 02:39 AM


All times are GMT. The time now is 01:30 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick