I would think the simplest way to handle this would be to add an additional condition inside your pre-existing condition (that is not related to Obama Care ) to test if "n2" is 0 (zero) before you attempt to divide by it:
e.g.
If the intention is not to show that you are dividing by zero, but to prevent it doing so altogether, you can amend the existing elif that handles that case to also check that "n2" is not zero. Talking of which, it may be better (simpler) to use a "case" statement instead of "if" - ifs can get a bit clumsy looking, when there's lots of elifs going on.
Hey can anyone tell me the korn script code to implement an interactive integer calculator using the shell's built in arithemetic expression evaluation (2 Replies)
I am pretty new to the Unix word, and have created a working calculator script. I have one problem. It doesn't use any decimals, it rounds off to the nearest whole number.
1 #!/bin/ksh
2 while true; do
3 echo -n "Enter the first integer: "; read IN1
4 test... (2 Replies)
hi, im new to the unix system and scripting and was wondering if anyone could help me with this problem iv been havin... i want the system to:
1. ask me for a number
2. ask me for a command to use on that number (* + - /)
3. ask me for another number
4. then ask me for another command, if the... (2 Replies)
I have 2 questions.
1) Is there a means of directing output to a file (">") while making it still output to the console?
I have a script that calls another lengthy script.
2) I can direct the output of the lengthy script and grep it for the words "good" or "bad" to know if I need the run... (2 Replies)
Hi Guys,
I found this code in net.. it is working fine..
But can anybody explain me the sed statement used in the code..
echo "Enter the expression:\c"
read express
eval echo "$express"|sed 's/^/'$precision' \
/'|bc -l|\
sed -n '1,${
/syntax/!{
}
... (2 Replies)
hi,
I have some problems in my simple script about the redirect echo stdout command inside a condition. Why is the echo command inside the elif still execute in the else command
Here are my simple script
After check on the two diff output the echo stdout redirect is present in two diff... (3 Replies)
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)
HI
My doubt may be basic one but I need to get it clarified..
When i use "if" condition that checks for many AND, OR logical conditions
like
if ]; then
return 0
fi
Even the if condition fails it returns as zero.. Any clue..
But if i add else condition like
if ]; ... (2 Replies)
I wrote a code to find codons in a DNA string. The only problem I have is how do I make the code only work for a file with DNA. This means the file only has the characters a,c,g,t and no white space characters. (3 Replies)
So have I got this :
#!/bin/bash
clear
echo "Enter the first number:"
read n1
echo "Choose an operation:"
echo "1. add"
echo "2. subtract"
echo "3. multiply"
echo "4. divide"
read opr
echo "Enter the second number:"
read n2 (1 Reply)
Discussion started by: mugiboya
1 Replies
LEARN ABOUT OSF1
plock
plock(2) System Calls Manual plock(2)NAME
plock - Locks a process' text and/or data segments in memory
SYNOPSIS
#include <sys/lock.h>
int plock( int opr) ;
PARAMETERS
Specifies one of the following operations: Locks the text and data segments into memory. Locks the text segment into memory. Locks the
data segment into memory. Removes locks.
DESCRIPTION
The plock() function locks or unlocks a process' text segments, data segments, or both in physical memory. When locked, the physical pages
containing the text or data segment will not be paged out. It is an error to lock a segment that is already locked.
The caller must have superuser privilege to use the plock() function.
Note that memory acquired subsequent to a plock() function may or may not be locked in memory, depending on the specific acquisition
method. Memory acquired using the brk() function (or the sbrk() function) is locked if the data segment was locked. Memory acquired via
the mmap() or vm_allocate() functions will not be locked.
RETURN VALUES
Upon successful completion, a value of 0 (zero) is returned to the calling process. Otherwise, a value of -1 is returned and errno is set
to indicate the error.
ERRORS
If the plock() function fails, errno may be set to one of the following values: The caller does not have appropriate privilege. There are
insufficient resources to perform the operation. The opr parameter is PROCLOCK, but the text segment or the data segment is already
locked. The opr parameter is TXTLOCK, but the text segment is already locked. The opr parameter is DATLOCK, but the data segment is
already locked. The opr parameter is UNLOCK, but neither the text segment nor the data segment is locked.
RELATED INFORMATION
Functions: brk(2), mmap(2) delim off
plock(2)