0

This is what I currently have so far.

The script needs to Add, Edit, Search, and View the address_file.

Any help would be greatly appreciated.

trap "rm ./f 2> /dev/null; exit" 0 1 3
addressfile=~/address_file
loop=x
while test $loop = "x"
do
 clear
 tput cup 3 12; echo "Address Book Menu"
 tput cup 4 12; echo "================="
 tput cup 6 9; echo "S - Search For Address"
 tput cup 7 9; echo "A - Add Address"
 tput cup 8 9; echo "R - Remove Address"
 tput cup 9 9; echo "E - Edit Address"
 tput cup 10 9; echo "V - View Address"
 tput cup 12 9; echo "Q - Quit"
 tput cup 12 19;
 read choice || continue
  case $choice in
     #  [Ss]  fnSearchPhone ;;
     [Aa]) fnPhoneAdd ;;
     [Rr]) fnPhoneDelete ;;
     # [Ee]) fnEditPhone ;;
     [Vv]) fnViewPhone ;;
     [Qq]) clear ; exit ;;
     *) tput cup 14 4; echo "Invalid Code"; read choice ;;
  esac
done

fnPhoneAdd()
{
  testloop=y
  while [ $looptest = y ]
  do
    clear
    tput cup 1 4; echo "Address Book Phone Addition"
    tput cup 2 4; echo "==========================="
    tput cup 4 4; echo "Full Name   : "
    tput cup 5 4; echo "Phone Number: "
    tput cup 6 4; echo "Office      : "
    tput cup 8 4; echo "Add Another? (y)es or (q)uit: "
 tput cup 4 18; read phonenum
    if [ "$phonenum" = "q" ]
           then
            clear ; exit
    fi
    tput cup 4 18; read name
    tput cup 5 18; phonenum
    tput cup 6 18; office
    if [ "$name} > "     " ]
    then
    echo "$name:$phonenum:$office" >> $addressfile
    fi
    tput cup 12 33; read testloop
    if [ "$testloop" = "q"]
     then
       clear ; exit
    fi
  done
}

fnPhoneDelete
{
  tput cup 16 4; echo "Delete Address Book Record"
tput cup 17 4; echo "Phone: "
  tput cup 17 11; read phonenum
  tput cup 18 4; echo "Accept? (y)es or (n)o: "
  tput cup 18 27; read Accept
  if test $Accept = "y"
         then
           sed /$number/d $addressfile > f
           cp f $addressfile
         rm f
  fi
  ;;
}
fnViewPhone
{
  clear ; less $addressfile
}

Edited by BTW8892: n/a

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by L7Sqr
0

I have corrected some of my minor errors, but now when I execute one of the options, I get the following error.

Address Book Menu
            =================

         S - Search For Address
         A - Add Address
         R - Remove Address
         E - Edit Address
         V - View Address

         Q - Quit  a
./addressbook: line 27: fnPhoneAdd: command not found
0

Considering your original example line 27 is empty. Perhaps is would help us if you provided your updated source file.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.