BASH: floating point exception

Hi, guys,

today, I have copied a simple script which runs correctly on a computer to another one. But, the latter informs me:

Floating point exception!

@ ./command_module a b c

where command_module is the module compiled by myself.

So, I have fixed it by following steps

  1. append the current directory of the command_module to PATH
  2. delete the characters of ./
  3. rename command_module as commandmodule, else the error is still informed.

So, my question is what is the reason for it? Although it seems that the script is running correctly again, I am confused... who knows why?

thanks!:slight_smile:

What is in that script?

What line causes that error?

What is the full error message?

What is '@'?

None of the steps you describe would fix that error, unless having the additional directory in your PATH caused the script to call a different version of a command.

[quote]

Thank you, cfajohnson!

To fix the problem, I

  1. add the current directory to the PATH (see the script)
    PATH=$PATH":$PWD"
    export PATH

  2. delete the "./" in the lines
    # ./$commandstr
    $commandstr

       \#   ./combine tests_inputs.txt > $cbfilename
        combine tests_inputs.txt > $cbfilename  
    
  3. rename the lp_solve as lpsolve

          \#    lp_solve -time -sp secure.lp 1> $lpfilename 2>&1
          lpsolve -time -sp secure.lp 1> $lpfilename 2>&1
    

The error "BASH: floating point exception " are outputed at the lines of
case 2 and 3.

And AutoRandom, lp_solve, lpsolve, combine are executable files compiled by myself.

The full error message:

+ ./lp_solve -time -sp secure.lp
./ExpScriptOld: line 55: 7304 Floating point exception./lp_solve -time -sp secure.lp >$lpfilename 2>&1

What is '@'?
@ is typed by myself. Sorry, just means AT.

The script is pasted here:
++++++++++++++++++++++++++++++++++++++++++++

#!/bin/bash -xv 
#This script is written for collecting time cost of lp_solve and a pruning algorithm.
#input: group_number, MAX_group_number, servicenumberforecahgroup,MAX_sn,task number,MAX_tn



# 3 loops
for ((gni=$1 ; gni<=$2 ;gni=gni+1))
do
        for ((sni=$3;sni<=$4;sni=sni+1))
        do
                for ((tni=$5;tni<=$6;tni=tni+1))
                do
                        #init commandstr
                        unset commandstr filestr
                        commandstr="AutoRandom $gni"

                        for ((ci=1;ci<=$gni;ci=ci+1))
                        do
                                commandstr="$commandstr $sni"

                        done
                        commandstr="$commandstr $tni"
                        
                        #call AutoRandom,output secure.lp, tests_inputs.txt
                        ./$commandstr
                       
                          
                        #init file name

                        unset lpfilename cbfilename
                        filestr="G_"$gni"S_"$sni"T_"$tni
                        lpfilename=lp$filestr
                        cbfilename=combine$filestr

                        echo $lpfilename $cbfilename
                        #call combine
                        ./combine tests_inputs.txt > $cbfilename
                        #grep the time cost
                      lptotalcost=` more $lpfilename | grep "solving" | sed 's/^.*(//g' | sed 's/s.*)$//g'`
                      lpParsingcost=` more $lpfilename | grep "Parsing" | sed 's/^.*input://g' | sed 's/s.*)$//g'`

                      cbtimecostL=`more $cbfilename | grep "^the.*linear" | sed 's/^.*takes//g' | sed 's/ milisecond$//g'`
                      cbtimecostA=`more $cbfilename | grep "advanced" | sed 's/^.*takes//g' | sed 's/ miliseconds$//g'`
                      

                     outputline="$filestr The cost time for LP_Parsing, LP_Total, L_Combine and A_Combine are: $lpParsingcost, $lptotalcost, $
cbtimecostL, $cbtimecostA"
                     echo $outputline >>  Data.txt


                done
        done
done

++++++++++++++++++++++++++++++++++++++++++++

[quote=cfajohnson;302225783]

What is in that script?

What line causes that error?

What is the full error message?
What is '@'?
None of the steps you describe would fix that error, unless having the additional directory in your PATH caused the script to call a different version of a command.

Sorry for the format of my reply.

The Tabs of the code are deleted by the thread editor.

Hi.

That's what the CODE tags are for. Select the text lines, then click the # above the editing window:

so the text looks like this in mono-space typeface

... cheers, drl

Thank u very much!

It works!:):b: