Thread: shell problem

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    1

    shell problem

    hi guys,
    i have here a little problem. shell is working fine, but when i enter all the info i need. i go to meniu command show all and i cant see the names i entered only e-mails. sry for my english ...
    Code:
    #!/bin/bash
    meniu()
    {
    dialog --backtitle "Book"\
           --title "meniu"\
           --menu "Choose:" 13 60 7\
            1 "New entry"\
            2 "Search"\
            3 "Show all"\
            4 "Delete entry" 2> temp
            a=`cat temp`
    case $a in
    1) dialog --backtitle "New entry" --inputbox "Name:" 20 50 4> temp
       d=`cat temp`
       dialog --backtitle "New entry" --inputbox "Surname:" 20 50 4> temp
       f=`cat temp`
       dialog --backtitle "New entry" --inputbox "Phone no.:" 20 50 4> temp
       h=`cat temp`
       dialog --backtitle "New entry" --inputbox "E-mail:" 10 50 2> temp
       l=`cat temp`
       echo "Name: $d Surname: $f Phone no.: $h E-mail: $l" >> kontaktai.txt
       meniu;;
    2) dialog --backtitle "Search" --inputbox "Search criteria" 20 50 4> temp
       y=`cat temp`
       dialog --backtitle "Search" --msgbox "`grep "$y" kontaktai.txt`" 5 100
       meniu;;
    3) dialog --backtitle "Show all" --title "List:" --msgbox "`sort kontaktai.txt`" 40 100
    meniu;;
    4) dialog --backtitle "Delete entry"\
              --menu "Choose" 10 50 2\
              1 "Delete single entry"\
              2 "Delete all entries" 2> temp
              pas=`cat temp`
    case $pas in
    1) dialog --backtitle "Delete entry" --inputbox "Įveskite duomenys:" 20 50 4> temp
       m=`cat temp`
       dialog --backtitle "Delete entry" --yesno "Ar tikrai norite ištrinti šį įrašą: `grep "$m" kontaktai.txt`?" 10 100
       c=$?
       case $c in
          0) dialog --backtitle "Delete entry" --msgbox "Įrašas ištrintas" 0 0
             grep -v "$m" kontaktai.txt > temp
             rm kontaktai.txt
             mv temp kontaktai.txt;;
          1) dialog --backtitle "Delete entry" --msgbox "Įrašas neištrintas" 5 50;;
          255) dialog --backtitle "Delete entry" --msgbox "paspausta Esc" 5 50;;
          esac
          meniu;;
    2) dialog --backtitle "Delete all entries" --yesno "Are u sure you want to delete all entries ?" 10 50
    x=$?
    case $x in
          0) dialog --backtitle "Delete all entries" --msgbox "Įrašai ištrinti" 0 0
    	 rm kontaktai.txt;;
          1) dialog --backtitle "Delete entry" --msgbox "Įrašas neištrintas" 5 50;;
          255) dialog --backtitle "Delete entry" --msgbox "paspausta Esc" 5 50;;
    esac
    meniu;;
    esac;;
    esac
    }
    meniu

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    If you run the "sort" command from the command line, does it show everything you expect to see?

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    I don't know the solution to your problem. I don't even understand the problem. But can't you use, in stead of:
    Code:
    dialog --backtitle "New entry" --inputbox "Surname:" 20 50 4> temp
    f=`cat temp`
    something like
    Code:
    f=`dialog --backtitle "New entry" --inputbox "Surname:" 20 50 4`
    Looks a lot better to me.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  2. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  3. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  4. binary tree problem - help needed
    By sanju in forum C Programming
    Replies: 4
    Last Post: 10-16-2002, 05:18 AM
  5. System.ini Shell Problems
    By (TNT) in forum Windows Programming
    Replies: 2
    Last Post: 08-26-2001, 01:05 PM