Bash problems

Dear Community

I am trying to determine a maximum illum value within a picture file then print the result if it is above a certain value. Here is where I am at the moment:

maxim=$(pextrem -o 9.pic | rcalc -e '$1=($3*0.265+$4*0.670+$5*0.065)*179' | total -u)
echo $maxim
if [ "$maxim" -gt 15000 ] ; then
pextrem -o 9.pic | rcalc -e '$1=($3*0.265+$4*0.670+$5*0.065)*179' total -u > 9.dat
fi
done

The problem: I keep getting the : integer expression expected warning. As far as I can see, $maxim is an integer as shown from the echo expression. Therefore I don't understand what I'm doing wrong here. Any pointers will be greatly appreciated.

Dan

Hi Dan,

it is easier then that. You can use the special variable cond in rcalc
to decide whether any output is to be generated or not.

pextrem -o 9.pic | rcalc -e 'illummax=($3*0.265+$4*0.670+$5*0.065)*179'
-e 'cond=if(illummax-15000,1,-1)' -e '$1=illummax' | total -u > 9.dat

does the job (ok, you will get an empty file 9.dat if the illuminance
value is below 15000).

Cheers, Lars.

Thanks for the speedy reply Lars. That's a tidy way of doing it but I still need to figure where my original expression is wrong as I also need to run some further expressions to the file if the result is true. Looking a bit more closely at the result it appears the expression creates a tab and extra line to the value...I wonder if this is why the script thinks the expression is not an integer?!

···

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Lars O. Grobe
Sent: 22 July 2009 18:47
To: Radiance general discussion
Subject: Re: [Radiance-general] Bash problems

Hi Dan,

it is easier then that. You can use the special variable cond in rcalc to decide whether any output is to be generated or not.

pextrem -o 9.pic | rcalc -e 'illummax=($3*0.265+$4*0.670+$5*0.065)*179'
-e 'cond=if(illummax-15000,1,-1)' -e '$1=illummax' | total -u > 9.dat

does the job (ok, you will get an empty file 9.dat if the illuminance value is below 15000).

Cheers, Lars.

Hi Dan,

It looks like you need a "|" in your second call to pextrem (before total). However since you have already calculated the value for maxim, why not just echo $maxim to 9.dat? Such as:

    maxim=$(pextrem -o 9.pic | rcalc -e '$1=($3*0.265+$4*0.670+$5*0.065)*179' | total -u)
    echo $maxim
    if [ "$maxim" -gt 15000 ] ; then
    echo $maxim > 9.dat
    fi
    done
      
-Jack

Dan Fitzpatrick wrote:

···

Dear Community

I am trying to determine a maximum illum value within a picture file then print the result if it is above a certain value. Here is where I am at the moment:

maxim=$(pextrem -o 9.pic | rcalc -e '$1=($3*0.265+$4*0.670+$5*0.065)*179' | total -u)
echo $maxim
if [ "$maxim" -gt 15000 ] ; then
pextrem -o 9.pic | rcalc -e '$1=($3*0.265+$4*0.670+$5*0.065)*179' total -u > 9.dat
fi
done

The problem: I keep getting the : integer expression expected warning. As far as I can see, $maxim is an integer as shown from the echo expression. Therefore I don't understand what I'm doing wrong here. Any pointers will be greatly appreciated.

Dan

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general
  
--
# Jack de Valpine
# president
#
# visarc incorporated
# http://www.visarc.com
#
# channeling technology for superior design and construction

Hi Jack,

Many tanks for the response. You're right, I did miss the "pipe" before total in the second call. However, the -gt element still thinks I need to express an integer when in fact it should be exactly that.

Dan

···

From: [email protected] [mailto:[email protected]] On Behalf Of Jack de Valpine
Sent: 22 July 2009 19:17
To: Radiance general discussion
Subject: Re: [Radiance-general] Bash problems

Hi Dan,

It looks like you need a "|" in your second call to pextrem (before total). However since you have already calculated the value for maxim, why not just echo $maxim to 9.dat? Such as:

maxim=$(pextrem -o 9.pic | rcalc -e '$1=($3*0.265+$4*0.670+$5*0.065)*179' | total -u)

echo $maxim

if [ "$maxim" -gt 15000 ] ; then

echo $maxim > 9.dat

fi

done

-Jack

Hi Dan,

I haven't really been following this thread, but did you try the "floor()" function around your rcalc expression to guarantee you get an integer result?

-Greg

···

From: Dan Fitzpatrick <[email protected]>
Date: July 22, 2009 10:29:11 AM PDT

Dear Community

I am trying to determine a maximum illum value within a picture file then print the result if it is above a certain value. Here is where I am at the moment:

maxim=$(pextrem -o 9.pic | rcalc -e '$1=($3*0.265+$4*0.670+$5*0.065)*179' | total -u)
echo $maxim
if [ "$maxim" -gt 15000 ] ; then
pextrem -o 9.pic | rcalc -e '$1=($3*0.265+$4*0.670+$5*0.065)*179' total -u > 9.dat
fi
done

The problem: I keep getting the : integer expression expected warning. As far as I can see, $maxim is an integer as shown from the echo expression. Therefore I don't understand what I'm doing wrong here. Any pointers will be greatly appreciated.

Dan

Hi Greg,

That seems to be it. Thank you so much.

-Dan

···

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Greg Ward
Sent: 22 July 2009 19:37
To: Radiance general discussion
Subject: Re: [Radiance-general] Bash problems

Hi Dan,

I haven't really been following this thread, but did you try the
"floor()" function around your rcalc expression to guarantee you get
an integer result?

-Greg