?
Solved

Batch to Bash

Posted on 2005-03-06
1
Medium Priority
?
3,921 Views
Last Modified: 2010-08-05
I would like to translate this to a bash script.

The current Windows batch script is:

@ECHO OFF
:LOOP
CLS
ECHO AP Biology Lab Selector
ECHO -----------------------
ECHO Lab 2: Enzyme Catalysis
ECHO Q to Quit
ECHO.
:: SET /P prompts for input and sets the variable
:: to whatever the user types
SET Choice=
SET /P Choice=Type lab number:
:: The syntax in the next line extracts the substring
:: starting at 0 (the beginning) and 1 character long
IF NOT '%Choice%'=='' SET Choice=%Choice:~0,1%
ECHO.
:: /I makes the IF comparison case-insensitive
IF /I '%Choice%'=='2' GOTO Item1
IF /I '%Choice%'=='Q' GOTO End
IF /I '%Choice%'=='Quit' GOTO End
ECHO "%Choice%" is not valid!
PAUSE
ECHO.
GOTO Loop
:Item1
CLS
ECHO Starting program...
::do stuff
GOTO Again
:Again
CLS
GOTO Loop
:End

Any help would be great.
0
Comment
Question by:partiallynothing
1 Comment
 
LVL 48

Accepted Solution

by:
Tintin earned 2000 total points
ID: 13472784
#!/bin/bash
while true
do
  clear
  cat <<EOF
AP Biology Lab Selector
-----------------------

Lab 2: Enzyme Catalysis
Q to Quit

EOF

  echo -n "Type lab number: "
  read choice

  case "$choice" in
  2)  #do stuff
      ;;
 q|Q) exit
      ;;
  *)  echo "$choice is not valid!"
      ;;
  esac

done
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…
Suggested Courses

593 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question