Sponsored Content
Full Discussion: division by 0 error
Top Forums Shell Programming and Scripting division by 0 error Post 302279475 by cfajohnson on Thursday 22nd of January 2009 08:40:58 PM
Old 01-22-2009
Quote:
Originally Posted by cat55
I am writing a script that among other things will be checking for various files on mount points. One of the conditions is that unless the server has failed over the df command will show root ( / ). If when checking the files the script comes across /, I want it to skip it, otherwise to complete the printf statement.
This portion of the script is

Please put code inside [code] tags (and forget all that silly FONT and SIZE crap).
Quote:
Code:
 if ${MNTD} == "/" then
        > /dev/null
 else
        printf '%12 ......


However, since that really isn't code ...
Quote:
When running, if the script comes across a / I am receiving a 'Division by 0' error and it will abort the query.

Why would you be using any of the mount points as a divisor?

Code:
[ "$MNTD" = / ] || printf ...

Or:

Code:
if [ "$MNTD" != / ]
then
   printf ...
fi

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

division problem

how can i show the value when i divide a number where the dividend is greater then the divisor. for example... 3 divided by 15 ---> let x=3/15 when i do this in the shell environment it gives me an output of 0. please help me. thanks. (3 Replies)
Discussion started by: inquirer
3 Replies

2. Shell Programming and Scripting

error "awk: (FILENAME=- FNR=23) fatal: division by zero attempted"

Hi , I have file : after i run this command : there are error can we print blank line if output error ?? thanks.. ^^ (4 Replies)
Discussion started by: justbow
4 Replies

3. UNIX for Dummies Questions & Answers

Division Error - Integer Error?

Hi All, I'm reasonably new to UNIX, and am having problems with a TSHELL script that I am using. The script is intended to cycle through a loop, and then divide the number in the counter by 10 and store the result in another variable. I am missing something simple here, but cannot work it out... (1 Reply)
Discussion started by: Col
1 Replies

4. Shell Programming and Scripting

Division by zero error message in AWK

How can I modify my awk code to get rid of the divion by zero error message? If I run the script without an input file, it should return error message "Input file missing" but not divison by zero. Code: #!/bin/nawk -f BEGIN { if (NR == 0) {print "Input file... (4 Replies)
Discussion started by: Pauline mugisha
4 Replies

5. Shell Programming and Scripting

awk error message: division by zero attempted

Hi, I'm executing unixbench tool v4.1 on an embedded system and I'm getting these error messages: Execl Throughput 1 2 3awk: /unixbench/unixbench-4.1.0/pgms/loops.awk:38: (FILENAME=- FNR=4) fatal: division by zero attempted Pipe Throughput 1 2 3 4 5 6 7 8 9 10awk:... (3 Replies)
Discussion started by: rogelio
3 Replies

6. Shell Programming and Scripting

division by zero

Hello, I am searching for a way to calculate for example 10/100 within a shellscript and the result should be 0.1 and not just 0. Every alternative i tried just results 0 Thank you in advance 2retti (6 Replies)
Discussion started by: 2retti
6 Replies

7. Shell Programming and Scripting

awk division error - 0

input 0 0 9820373 2069 0 0 11485482 awk '{print ($1/$3) / ($4/$7)}' input error Is there any way to fix this problem ? (25 Replies)
Discussion started by: quincyjones
25 Replies

8. UNIX for Dummies Questions & Answers

Help in division

hi, The below commands result only the whole number(not giving the decimal values). pandeeswaran@ubuntu:~$ echo 1,2,3,4|sed 's/,/\//g'|bc 0 pandeeswaran@ubuntu:~$ echo 1000,2,3|sed 's/,/\//g'|bc 166 How to make it to return the decimal values? Thanks (5 Replies)
Discussion started by: pandeesh
5 Replies

9. Shell Programming and Scripting

awk - continue when encountered division error

Hello, How can I add a logic to awk to tell it to print 0 when encountering a division by zero attempted? Below is the code. Everything in the code works fine except the piece that I want to calculate read/write IO size. I take the kbr / rs and kbw / ws. There are times when the iostat data... (5 Replies)
Discussion started by: tommyd
5 Replies

10. Shell Programming and Scripting

Division by zero attempted error during linear conversion of values between 0.25 to 1

I want to implement the below formula with awk oneliner new_value = ((old_value - old_min) / (old_max - old_min) ) * (new_max - new_min) + new_min I want to pass the value of old_min and old_min as variable. Here is what I did for this old_min=$(awk 'BEGIN{a=100000000000}{if ($10<0+a) a=$10}... (2 Replies)
Discussion started by: sammy777888
2 Replies
MESSAGES(3)						  libbash messages Library Manual					       MESSAGES(3)

NAME
messages -- libbash library that implements a set of functions to print standard status messages SYNOPSIS
printOK [indent] printFAIL [indent] printNA [indent] printATTN [indent] printWAIT [indent] DESCRIPTION
General messages is a collection of functions to print standard status messages - those [ OK ] and [FAIL] messages you see during Linux boot process. The function list: printOK Prints a standard [ OK ] message (green) printFAIL Prints a standard [FAIL] message (red) printNA Prints a standard [ N/A] message (yellow) printATTN Prints a standard [ATTN] message (yellow) printWAIT Prints a standard [WAIT] message (yellow) Detailed interface description follows. indent Column to move to before printing. Default indent is calculated as TTY_WIDTH-10. If current tty width can not be determined (for example, in case of serial console), it defaults to 80, so default indent is 80-10=10 FUNCTIONS DESCRIPTIONS
printOK [indent] Prints a standard [ OK ] message (green) printFAIL [indent] Prints a standard [FAIL] message (red) printNA [indent] Prints a standard [ N/A] message (yellow) printATTN [indent] Prints a standard [ATTN] message (yellow) printWAIT [indent] Prints a standard [WAIT] message (yellow) EXAMPLES
Run a program named MyProg, and report it's success or failure: echo -n 'Running MyProg...' printWAIT if MyProg ; then printOK else printFAIL fi AUTHORS
Hai Zaar <haizaar@haizaar.com> Gil Ran <gil@ran4.net> SEE ALSO
ldbash(1), libbash(1) Linux Epoch Linux
All times are GMT -4. The time now is 06:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy