1828983 Members
2163 Online
109986 Solutions
New Discussion

If conndition error

 
SOLVED
Go to solution
bullz
Super Advisor

If conndition error

hello all,

Wen i try the below if condition i am geting the below error.

fs_check.sh[24]: 65%: Expression is not complete; more tokens expected.
9 REPLIES 9
Steven E. Protter
Exalted Contributor

Re: If conndition error

Shalom,

Provide a script snip.

Most likely its just a syntax error in and if ... fi or similar loop.

Without the code its hard to tell.

Get me the entire condition loop and a few lines above. Sometimes an expression above line 24 in this case triggers the error by not being closed.

Look for variables being tested that have no declared data, things like that.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com

Re: If conndition error

using my crystal ball and psychic abilities I'm guessing you have a script which parses the output of the bdf command looking for filesystems that are filling up?

I'm then going to go on and guess that if you run bdf manually you will see one of the filesystems being split across 2 lines, and this is what is upsetting your script...

And finally I'm going to suggest that instead of re-inventing the wheel, you simply use Bill Hassell's bdfmegs utility to do what you need:

http://forums13.itrc.hp.com/service/forums/questionanswer.do?threadId=1326767

If I'm way off the mark here then apologies...

HTH

Duncan

I am an HPE Employee
Accept or Kudo
bullz
Super Advisor

Re: If conndition error

HI

Just below is my coed.
Its woking 5n for solairs servers.

I guess some problem in IF condition :(

#!/bin/sh
#
touch /tmp/mountpoint_output.txt
rm /tmp/mountpoint_output.txt
touch /tmp/mountpoint_output.txt
/usr/bin/clear
OS_TYPE=`uname -s`
Dat=`date +%d/%m/%y`
if [ "$OS_TYPE" = "HP-UX" ]
then
cont=`bdf | awk '{if (NF==1) {line=$0;getline;sub(" *"," ");print line$0} else {print}}' | wc -l`
cnt=`expr $cont - 1`
bdf | awk '{if (NF==1) {line=$0;getline;sub(" *"," ");print line$0} else {print}}' | tail -$cnt | awk '{print $5"#"$6}' > /tmp/mountpoint.txt
else
cont=`df -k | wc -l`
cnt=`expr $cont - 1`
df -k | tail -$cnt | awk '{print $5"#"$6}' > /tmp/mountpoint.txt
fi
i=`cat /tmp/mountpoint.txt`
for x in $i
do
mountpoint_size=`echo $x | awk -F"#" '{print $1}'`
mountpoint_name=`echo $x | awk -F"#" '{print $2}'`
if [ "$mountpoint_size" -gt 30% ]
then
echo "Mountpoint $mountpoint_name is $mountpoint_size full" >> /tmp/mountpoint_output.txt
echo "----------------------------------------------------------------------" >> /tmp/mountpoint_output.txt
if [ "$OS_TYPE" = "HP-UX" ]
then
du -akx $mountpoint_name | sort -nr | head -50 >> /tmp/mountpoint_output.txt
else
du -akd $mountpoint_name | sort -nr | head -50 >> /tmp/mountpoint_output.txt
fi
echo "----------------------------------------------------------------------" >> /tmp/mountpoint_output.txt
fi
done
James R. Ferguson
Acclaimed Contributor
Solution

Re: If conndition error

Hi:

> fs_check.sh[24]: 65%: Expression is not complete; more tokens expected.

...points to line-24, not the 'if' condition involving the OS_TYPE.

However, your problem is:

if [ "$mountpoint_size" -gt 30% ]

...which should be something like:

if [ $(echo "$mountpoint_size"|sed -e s/%//) -gt 30 ]

...to remove the "%" character

Regards!

...JRF...
Ralph Grothe
Honored Contributor

Re: If conndition error

>if [ $(echo "$mountpoint_size"|sed -e s/%//) -gt 30 ]
>
>...to remove the "%" character

If he's using the hp shell this could also be written without invoking sed


if [[ ${mountpoint_size%\%} > 30 ]]; then
Madness, thy name is system administration
bullz
Super Advisor

Re: If conndition error

Thank you so much James, Its working 5n when i execute it in HP-UX server

But wen i try the same on solaris server, I am geting an error as shown below :(

could you please help me on this?

fs_check.sh: syntax error at line 24: `(' unexpected

I guess, solairs server not accepting IF condition accordinlgy :(
Ralph Grothe
Honored Contributor

Re: If conndition error

I guess the standard shell on Solaris (which release?) is some ancient pre-posix one.
So try replacing the $(...) expression for your Solaris version by a pair of backticks `...`,
or better change to a more modern shell.
Madness, thy name is system administration

Re: If conndition error

IIRC Solaris defaults to the crusty old Bourne shell so won't understand that POSIX syntax...

Instead of

if [ $(echo "$mountpoint_size"|sed -e s/%//) -gt 30 ]

try:

if [ `echo "$mountpoint_size"|sed -e s/%//` -gt 30 ]

HTH

Duncan

I am an HPE Employee
Accept or Kudo
bullz
Super Advisor

Re: If conndition error

Thank you so much Duncan