Multiple Choice/Fill-In-The-Blank Shell Script

Discussion in 'Mac Programming' started by daviesgeek, Jul 13, 2011.

  1. daviesgeek macrumors newbie

    daviesgeek

    Joined:
    Jul 10, 2011
    Location:
    USA!
    #1
    How do you write a shell script with multiple choice answers and fill-in-the-blank answers? I have tried Googling this, but I didn't come up with anything. Thanks in advance for your help.
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    quest.sh
    Code:
    #!/bin/bash
    
    echo "What is the capital of Assyria?"
    echo 1. Rome
    echo 2. Boston
    echo 3. Assur
    echo 4. Coconuts
    read answer
    if [ "$answer" -ne 3 ] ;
    then
     echo "Into the gorge you go!"
    else
     echo "You may pass."
    fi
    
    For fun, replace echo with say.
     

Share This Page