Script - loop


Results 1 to 3 of 3

Thread: Script - loop

  1. #1
    Join Date
    Jul 2003
    Posts
    2,021

    Script - loop

    Hi folks,

    I have following script as looping. It takes up space.

    Script:-
    Code:
    .... 
    # Choosing preset directores for copying
    REPLY="B"
    until [ -z "$REPLY" ]
    
    do
    echo "Choose any of the following:"
    echo
    echo "[B]123"
    echo "[C]123"
    echo "[D]123"
    echo "[A]ll
    echo
    echo "[Enter] = Exit"
    echo
    
    read
    
    case "$REPLY" in
    
    # Accept upper or lowercase input...
    "B" | "b" )
    B123
    ;;
    
    "C" | "c" )
    C123
    ;;
    
    "D" | "d" )
    D123
    ;;
    
    "A" | "a" )
    B123
    C123
    D123
    ;;
    
    * )
    #Default option.
    # Do nothing for other keys
    ;;
    
    esac
    done
    
    .....
    .....
    It has been rearranged in a shorter form to save space as follow;

    Script:-
    Code:
    .... 
    ....
    choices="[B]123 [C]123 [D]123 [A]ll [Enter]=Exit"
    echo "Choose one of the following:"
    for choice in $choices ; do echo $choice ; done
    
    read reply
    
    case $reply in
    [Bb]*) B123 ;;
    [Cc]*) C123 ;;
    [Dd]*) D123 ;;
    [Aa]*) B123 ; C123 ; D123 ;;
    *) echo "Exiting..." ; exit ;;
    esac
    .....
    .....
    But it is not a loop only running once. Is there any suggestion. TIA

    B.R.
    satimis

  2. #2
    Join Date
    Apr 2003
    Location
    Buenos Aires, Argentina
    Posts
    4,219
    case is not for looping, you have to use while/until. Where do you want it to loop?
    djserz.com.ar
    "All the drugs in this world won't save you from yourself..."

  3. #3
    Join Date
    Jul 2003
    Posts
    2,021
    Originally posted by serz
    case is not for looping, you have to use while/until. Where do you want it to loop?
    Hi serz,

    Those directories are for creating ISO image and then burning CD

    # Temporary files to store for resulting mkisofs command
    CmdFile=/tmp/satimis/.TmpBurnCD$$
    list=""
    ......

    B.R.
    satimis

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •