Sponsored Content
Top Forums Shell Programming and Scripting Doing simple math for children. Post 302517969 by devrymike on Thursday 28th of April 2011 10:49:51 AM
Old 04-28-2011
You're creating an infinite loop with this. Once it's wrong, it never exits because you never get a new value.

Code:
 
while (( $antwoordleerling != $antwoordjuiste ))
do
echo "Fout! Probeer het nogmaals $getallinks x $getalrechts =" 
read $getallinks x $getalrechts

I think this should fix it and work to your liking.

Code:
 
#!/bin/bash
while true
do
getallinks=$((RANDOM/(32767/10)+1))
getalrechts=$((RANDOM/(32767/10)+1))
echo "Hoeveel is $getallinks x $getalrechts ?"
read antwoordleerling
antwoordjuiste=$((getallinks*getalrechts))
if test  $antwoordleerling == $antwoordjuiste 
then
echo "Goed zo! $getallinks x $getalrechts is inderdaad $antwoordjuiste."
else
while (( $antwoordleerling != $antwoordjuiste ))
do
echo "Fout! Probeer het nogmaals $getallinks x $getalrechts =" 
read antwoordleerling
done
fi
done

 

8 More Discussions You Might Find Interesting

1. Programming

Father & children

Hello, i should finished this program, if anyone could tell me whats wrong... This is an optional university work, though i cant leave this nearly finished. I need to see where is my error :( What my program should do. The user must type "num_proc" ( number of children). The program creates a... (4 Replies)
Discussion started by: Jariya
4 Replies

2. UNIX for Advanced & Expert Users

How to follow processes and their children with ps

Hi, I often need to find the child processes of a parent process. There may be a string of 4-5. That is, PPID 884 spawns 890, which spawns 894, which spawns 1017. I'd like to be able to see all of them without having to type in a number of ps -ef commands. Process groups and session ID's are... (2 Replies)
Discussion started by: mschwage
2 Replies

3. UNIX for Dummies Questions & Answers

Simple Math question...

Hi All , I'm trying to do a simple math expression ...but unsuccessfull :-( Anyone can help me? days=23 amount=`expr ${days} / 30 \* -125` echo $amount but as result i got 0 when i expect 95.833333 Another question...how i can limit only to two or three decimal fields? Thanks in... (1 Reply)
Discussion started by: EDBGSK
1 Replies

4. Shell Programming and Scripting

Prepend name of directory to children folders

Hi, I am a shell scripting newbie. I am in need of a shell script that will prepend the name of the parent directory to the child directory. For example if the shell script called rename.sh is invoked with ">rename.sh /home/foobar/Simple" and the structure of the folder Simple is : Simple... (7 Replies)
Discussion started by: kalichar
7 Replies

5. UNIX for Advanced & Expert Users

Fork() 1 Parent 3 Children

Hi, as I understand fork(), it makes a copy of the parent which becomes a child. But is there anyway to make three children for that one parent. So in other words, if I look up the getppid() of the children, I want them to have the same value?? Thanks in advance to any help! (1 Reply)
Discussion started by: MS_CC
1 Replies

6. Shell Programming and Scripting

Killing process and children

Hi all, I have been searching all day for a nice solution to this problem. I have three scripts. A start script, a child script and a stop script. Script A (scripta.sh) Its Child Script B (scriptb.sh) Script C (kill_process.sh $PID) Script A correctly traps the kill command sent from... (6 Replies)
Discussion started by: mark007
6 Replies

7. Programming

Multiple children and single pipe

Greetings everyone, I need a bit of help in solving the following problem: I'm given an array of numbers and I have to compute the sum of the array elements using n processes, and the inter process communication has to be done with pipes(one pipe, to be exact). I managed to solve the problem... (14 Replies)
Discussion started by: ephesos
14 Replies

8. Shell Programming and Scripting

pstree but without other children of ancestors

Hi, I want to display the process tree of a given PID, however, I don't want to see other children of the ancestors that don't reach the current PID. My goal is, from the tree result, i have to fetch a particular parent process by keyword, and if any other children from parents have the same... (2 Replies)
Discussion started by: ysrini
2 Replies
echo(3XCURSES)						  X/Open Curses Library Functions					    echo(3XCURSES)

NAME
echo, noecho - enable/disable terminal echo SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int echo(void); int noecho(void); DESCRIPTION
The echo() function enables Echo mode for the current screen. The noecho() function disables Echo mode for the current screen. Initially, curses software echo mode is enabled and hardware echo mode of the tty driver is disabled. The echo() and noecho() functions control soft- ware echo only. Hardware echo must remain disabled for the duration of the application, else the behavior is undefined. RETURN VALUES
Upon successful completion, these functions return OK. Otherwise, they return ERR. ERRORS
No errors are defined. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
getch(3XCURSES), getstr(3XCURSES), initscr(3XCURSES), libcurses(3XCURSES), scanw(3XCURSES), attributes(5), standards(5) SunOS 5.11 5 Jun 2002 echo(3XCURSES)
All times are GMT -4. The time now is 04:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy