?
Solved

Batch to Bash

Posted on 2005-03-06
1
Medium Priority
?
3,918 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

771 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