01-17-2013
Thank you for the responce, however, i do not have a problem with looping the code. My big issue, is getting the code to work like an actual calculator.
Basically I would like the script to
1 - Prompt the user for a number.
2 - Prompt the user for the operation they would like to perform, either add, subtract, multiply or divide.
3 - Prompt the user for a number.
4 - Prompt the user for the operation they would like to perform, either add, subtract, multiply, divide
OR EQUALS.
5 - Display the result of the selected operation. The script should then exit or continue from step 3 if the user has not selected equals.
It is the (continue from step 3) bit that I just cannot get to work. Any ideas. Any help is very welcome, i have been racking my brains with this for too long now
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am very new to Unix and don't know much about it. I've been trying to create a menu and what I don't understand is how to execute a command once a user makes a selection. I have the menu set up. In fact, the following is the code that I have thus far:
#! /bin/csh
# This is the UNIX menu... (0 Replies)
Discussion started by: sinjin
0 Replies
2. Shell Programming and Scripting
Hi there. I'm trying to teach myself UNIX but the book I bought is a bit confusing. I'm trying out this exercise and I think I'm on the right track, but I'd appreciate any suggestions on how to improve what I have so far. Also, I'm not clear on how to use the read command to utilize the user's... (3 Replies)
Discussion started by: Jsmith
3 Replies
3. UNIX for Dummies Questions & Answers
hey all, me again....having a problem with my code, where I essentially am trying to show a menu, have the user select an option (from 1 to 5), then display which selection they picked...
#!/bin/bash
# A LIST OF THE ERROR MESSAGES AND THE PROPER SYNTAX:
error_0="Correct amount of... (1 Reply)
Discussion started by: SoVi3t
1 Replies
4. Shell Programming and Scripting
Hopefully I'm in the right place. Im new to the forums and linux!
I'm looking to add a menu to my perl hangman game i have created. The menu will use user input for the desired option and then perform the operation indicated. I would like something along the lines of:
Welcome to Hangman... (1 Reply)
Discussion started by: jahburmski
1 Replies
5. Shell Programming and Scripting
Hi, I am trying to make a maths calculator that:
1. Prompts the user for a number.
2. Prompts the user for an operation (add, subtract, divide or multiply)
3. Prompts the user for a number.
4. Prompts the user for another operation (same as above) OR the option to get the result for the... (4 Replies)
Discussion started by: johnthebaptist
4 Replies
6. Shell Programming and Scripting
EDIT : System used : Any Linux distribution.
Hello everyone,
I m having quite a headache trying to figure out why I m having a 2 columns output in the following code :
#!/bin/ksh
menu_rotation()
{
#Variables
CHOIX1="Rotation 1"
CHOIX2="Rotation 2"
CHOIX3="Rotation 3"
... (11 Replies)
Discussion started by: Sekullos
11 Replies
7. UNIX for Dummies Questions & Answers
Dear Sir,
May I know how do I go about adding the following feature into the script below:
When user enter values other than 1,2,3,4,
a) Message “Wrong entry !!! Pls select 1,2,3 or 4” is displayed
b) The screen is cleared again and the menu is displayed.
#!/bin/bash
clear
var=1... (2 Replies)
Discussion started by: fusetrips
2 Replies
8. Homework & Coursework Questions
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known/data:
Script a simple calculator. In the command line enter the script file
/home/etc/mycalc or /home/etc/mycalc 1 +... (6 Replies)
Discussion started by: herb bertz
6 Replies
9. Shell Programming and Scripting
A lot of my scripting makes use of the 'select' command to create menu driven input. A typical example of how I use it is as:
somevar=''
PS3='Select one: '
while ]; do
select somevar in $(sqlplus -s $dbuser/$dbpw@mydb <<EOF
set echo off feedback off verify off... (7 Replies)
Discussion started by: edstevens
7 Replies
10. Shell Programming and Scripting
ADE is a UNIX environment for the ancient AMIGA A1200. By default this does NOT have the 'bc' command line calculator.
Although I did a DEMO code to create a C source and compile it under python 1.4.0 and ADE using ksh88 and the gcc of the day, I decided to create this baby that requires no Python... (2 Replies)
Discussion started by: wisecracker
2 Replies
RBASH(1) General Commands Manual RBASH(1)
NAME
rbash - restricted bash, see bash(1)
RESTRICTED SHELL
If bash is started with the name rbash, or the -r option is supplied at invocation, the shell becomes restricted. A restricted shell is
used to set up an environment more controlled than the standard shell. It behaves identically to bash with the exception that the follow-
ing are disallowed or not performed:
o changing directories with cd
o setting or unsetting the values of SHELL, PATH, ENV, or BASH_ENV
o specifying command names containing /
o specifying a file name containing a / as an argument to the . builtin command
o specifying a filename containing a slash as an argument to the -p option to the hash builtin command
o importing function definitions from the shell environment at startup
o parsing the value of SHELLOPTS from the shell environment at startup
o redirecting output using the >, >|, <>, >&, &>, and >> redirection operators
o using the exec builtin command to replace the shell with another command
o adding or deleting builtin commands with the -f and -d options to the enable builtin command
o using the enable builtin command to enable disabled shell builtins
o specifying the -p option to the command builtin command
o turning off restricted mode with set +r or set +o restricted.
These restrictions are enforced after any startup files are read.
When a command that is found to be a shell script is executed, rbash turns off any restrictions in the shell spawned to execute the script.
SEE ALSO
bash(1)
GNU Bash-4.0 2004 Apr 20 RBASH(1)